New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
is_const.hpp in vendors/XIOS/current/extern/boost/include/boost/type_traits – NEMO

source: vendors/XIOS/current/extern/boost/include/boost/type_traits/is_const.hpp @ 3428

Last change on this file since 3428 was 3428, checked in by rblod, 12 years ago

importing initial XIOS vendor drop

File size: 5.1 KB
Line 
1
2//  (C) Copyright Dave Abrahams, Steve Cleary, Beman Dawes,
3//      Howard Hinnant and John Maddock 2000.
4//  (C) Copyright Mat Marcus, Jesse Jones and Adobe Systems Inc 2001
5
6//  Use, modification and distribution are subject to the Boost Software License,
7//  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8//  http://www.boost.org/LICENSE_1_0.txt).
9//
10//  See http://www.boost.org/libs/type_traits for most recent version including documentation.
11
12//    Fixed is_pointer, is_reference, is_const, is_volatile, is_same,
13//    is_member_pointer based on the Simulated Partial Specialization work
14//    of Mat Marcus and Jesse Jones. See  http://opensource.adobe.com or
15//    http://groups.yahoo.com/group/boost/message/5441
16//    Some workarounds in here use ideas suggested from "Generic<Programming>:
17//    Mappings between Types and Values"
18//    by Andrei Alexandrescu (see http://www.cuj.com/experts/1810/alexandr.html).
19
20
21#ifndef BOOST_TT_IS_CONST_HPP_INCLUDED
22#define BOOST_TT_IS_CONST_HPP_INCLUDED
23
24#include <boost/config.hpp>
25#include <boost/detail/workaround.hpp>
26
27#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
28#   include <boost/type_traits/detail/cv_traits_impl.hpp>
29#   ifdef __GNUC__
30#       include <boost/type_traits/is_reference.hpp>
31#   endif
32#   if BOOST_WORKAROUND(BOOST_MSVC, < 1400)
33#       include <boost/type_traits/remove_bounds.hpp>
34#   endif
35#else
36#   include <boost/type_traits/is_reference.hpp>
37#   include <boost/type_traits/is_array.hpp>
38#   include <boost/type_traits/detail/yes_no_type.hpp>
39#   include <boost/type_traits/detail/false_result.hpp>
40#endif
41
42// should be the last #include
43#include <boost/type_traits/detail/bool_trait_def.hpp>
44
45namespace boost {
46
47#if defined( __CODEGEARC__ )
48
49BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_const,T,__is_const(T))
50
51#elif !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
52
53namespace detail{
54//
55// We can't filter out rvalue_references at the same level as
56// references or we get ambiguities from msvc:
57//
58template <class T>
59struct is_const_rvalue_filter
60{
61#if BOOST_WORKAROUND(BOOST_MSVC, < 1400)
62   BOOST_STATIC_CONSTANT(bool, value = ::boost::detail::cv_traits_imp<typename boost::remove_bounds<T>::type*>::is_const);
63#else
64   BOOST_STATIC_CONSTANT(bool, value = ::boost::detail::cv_traits_imp<T*>::is_const);
65#endif
66};
67#ifndef BOOST_NO_RVALUE_REFERENCES
68template <class T>
69struct is_const_rvalue_filter<T&&>
70{
71   BOOST_STATIC_CONSTANT(bool, value = false);
72};
73#endif
74}
75
76//* is a type T  declared const - is_const<T>
77BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_const,T,::boost::detail::is_const_rvalue_filter<T>::value)
78BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T&,false)
79
80#if  defined(BOOST_ILLEGAL_CV_REFERENCES)
81// these are illegal specialisations; cv-qualifies applied to
82// references have no effect according to [8.3.2p1],
83// C++ Builder requires them though as it treats cv-qualified
84// references as distinct types...
85BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T& const,false)
86BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T& volatile,false)
87BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T& const volatile,false)
88#endif
89
90#if defined(__GNUC__) && (__GNUC__ < 3)
91// special case for gcc where illegally cv-qualified reference types can be
92// generated in some corner cases:
93BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T const,!(::boost::is_reference<T>::value))
94BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T volatile const,!(::boost::is_reference<T>::value))
95#endif
96
97#else
98
99namespace detail {
100
101using ::boost::type_traits::yes_type;
102using ::boost::type_traits::no_type;
103
104yes_type is_const_tester(const volatile void*);
105no_type is_const_tester(volatile void *);
106
107template <bool is_ref, bool array>
108struct is_const_helper
109    : ::boost::type_traits::false_result
110{
111};
112
113template <>
114struct is_const_helper<false,false>
115{
116    template <typename T> struct result_
117    {
118        static T* t;
119        BOOST_STATIC_CONSTANT(bool, value = (
120            sizeof(boost::detail::yes_type) == sizeof(boost::detail::is_const_tester(t))
121            ));
122    };
123};
124
125template <>
126struct is_const_helper<false,true>
127{
128    template <typename T> struct result_
129    {
130        static T t;
131        BOOST_STATIC_CONSTANT(bool, value = (
132            sizeof(boost::detail::yes_type) == sizeof(boost::detail::is_const_tester(&t))
133            ));
134    };
135};
136
137template <typename T>
138struct is_const_impl
139    : is_const_helper<
140          is_reference<T>::value
141        , is_array<T>::value
142        >::template result_<T>
143{
144};
145
146BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_const,void,false)
147#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
148BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_const,void const,true)
149BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_const,void volatile,false)
150BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_const,void const volatile,true)
151#endif
152
153} // namespace detail
154
155//* is a type T  declared const - is_const<T>
156BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_const,T,::boost::detail::is_const_impl<T>::value)
157
158#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
159
160} // namespace boost
161
162#include <boost/type_traits/detail/bool_trait_undef.hpp>
163
164#endif // BOOST_TT_IS_CONST_HPP_INCLUDED
165
Note: See TracBrowser for help on using the repository browser.