blob: 07af0b42a99bad655d51922cac2b0eb687c6f3ec [file] [log] [blame]
Jeff Thompsonf7d49942013-08-01 16:47:40 -07001
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_VOLATILE_HPP_INCLUDED
22#define BOOST_TT_IS_VOLATILE_HPP_INCLUDED
23
Jeff Thompson2277ce52013-08-01 17:34:11 -070024#include <ndnboost/config.hpp>
25#include <ndnboost/detail/workaround.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070026
27#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Jeff Thompson2277ce52013-08-01 17:34:11 -070028# include <ndnboost/type_traits/detail/cv_traits_impl.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070029# if BOOST_WORKAROUND(BOOST_MSVC, < 1400)
Jeff Thompson2277ce52013-08-01 17:34:11 -070030# include <ndnboost/type_traits/remove_bounds.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070031# endif
32#else
Jeff Thompson2277ce52013-08-01 17:34:11 -070033# include <ndnboost/type_traits/is_reference.hpp>
34# include <ndnboost/type_traits/is_array.hpp>
35# include <ndnboost/type_traits/detail/yes_no_type.hpp>
36# include <ndnboost/type_traits/detail/false_result.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070037#endif
38
39// should be the last #include
Jeff Thompson2277ce52013-08-01 17:34:11 -070040#include <ndnboost/type_traits/detail/bool_trait_def.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070041
42namespace ndnboost {
43
44namespace detail{
45template <class T>
46struct is_volatile_rval_filter
47{
48#if BOOST_WORKAROUND(BOOST_MSVC, < 1400)
49 BOOST_STATIC_CONSTANT(bool, value = ::ndnboost::detail::cv_traits_imp<typename ndnboost::remove_bounds<T>::type*>::is_volatile);
50#else
51 BOOST_STATIC_CONSTANT(bool, value = ::ndnboost::detail::cv_traits_imp<T*>::is_volatile);
52#endif
53};
54#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
55//
56// We can't filter out rvalue_references at the same level as
57// references or we get ambiguities from msvc:
58//
59template <class T>
60struct is_volatile_rval_filter<T&&>
61{
62 BOOST_STATIC_CONSTANT(bool, value = false);
63};
64#endif
65}
66
67#if defined( __CODEGEARC__ )
68BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_volatile,T,__is_volatile(T))
69#elif !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
70
71//* is a type T declared volatile - is_volatile<T>
72BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_volatile,T,::ndnboost::detail::is_volatile_rval_filter<T>::value)
73BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_volatile,T&,false)
74
75#if defined(BOOST_ILLEGAL_CV_REFERENCES)
76// these are illegal specialisations; cv-qualifies applied to
77// references have no effect according to [8.3.2p1],
78// C++ Builder requires them though as it treats cv-qualified
79// references as distinct types...
80BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_volatile,T& const,false)
81BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_volatile,T& volatile,false)
82BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_volatile,T& const volatile,false)
83#endif
84
85#else
86
87namespace detail {
88
89using ::ndnboost::type_traits::yes_type;
90using ::ndnboost::type_traits::no_type;
91
92yes_type is_volatile_tester(void const volatile*);
93no_type is_volatile_tester(void const*);
94
95template <bool is_ref, bool array>
96struct is_volatile_helper
97 : public ::ndnboost::type_traits::false_result
98{
99};
100
101template <>
102struct is_volatile_helper<false,false>
103{
104 template <typename T> struct result_
105 {
106 static T* t;
107 BOOST_STATIC_CONSTANT(bool, value = (
108 sizeof(ndnboost::detail::yes_type) == sizeof(ndnboost::detail::is_volatile_tester(t))
109 ));
110 };
111};
112
113template <>
114struct is_volatile_helper<false,true>
115{
116 template <typename T> struct result_
117 {
118 static T t;
119 BOOST_STATIC_CONSTANT(bool, value = (
120 sizeof(ndnboost::detail::yes_type) == sizeof(ndnboost::detail::is_volatile_tester(&t))
121 ));
122 };
123};
124
125template <typename T>
126struct is_volatile_impl
127 : public is_volatile_helper<
128 is_reference<T>::value
129 , is_array<T>::value
130 >::template result_<T>
131{
132};
133
134BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_volatile,void,false)
135#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
136BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_volatile,void const,false)
137BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_volatile,void volatile,true)
138BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_volatile,void const volatile,true)
139#endif
140
141} // namespace detail
142
143//* is a type T declared volatile - is_volatile<T>
144BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_volatile,T,::ndnboost::detail::is_volatile_impl<T>::value)
145
146#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
147
148} // namespace ndnboost
149
Jeff Thompson2277ce52013-08-01 17:34:11 -0700150#include <ndnboost/type_traits/detail/bool_trait_undef.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700151
152#endif // BOOST_TT_IS_VOLATILE_HPP_INCLUDED