]> git.sesse.net Git - casparcg/blob - dependencies64/boost/boost/detail/is_incrementable.hpp
Merge pull request #374 from hummelstrand/readme-2.1.0-update
[casparcg] / dependencies64 / boost / boost / detail / is_incrementable.hpp
1 // Copyright David Abrahams 2004. Use, modification and distribution is
2 // subject to the Boost Software License, Version 1.0. (See accompanying
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4 #ifndef IS_INCREMENTABLE_DWA200415_HPP
5 # define IS_INCREMENTABLE_DWA200415_HPP
6
7 # include <boost/type_traits/detail/template_arity_spec.hpp>
8 # include <boost/type_traits/remove_cv.hpp>
9 # include <boost/mpl/aux_/lambda_support.hpp>
10 # include <boost/mpl/bool.hpp>
11 # include <boost/detail/workaround.hpp>
12
13 // Must be the last include
14 # include <boost/type_traits/detail/bool_trait_def.hpp>
15
16 namespace boost { namespace detail { 
17
18 // is_incrementable<T> metafunction
19 //
20 // Requires: Given x of type T&, if the expression ++x is well-formed
21 // it must have complete type; otherwise, it must neither be ambiguous
22 // nor violate access.
23
24 // This namespace ensures that ADL doesn't mess things up.
25 namespace is_incrementable_
26 {
27   // a type returned from operator++ when no increment is found in the
28   // type's own namespace
29   struct tag {};
30   
31   // any soaks up implicit conversions and makes the following
32   // operator++ less-preferred than any other such operator that
33   // might be found via ADL.
34   struct any { template <class T> any(T const&); };
35
36   // This is a last-resort operator++ for when none other is found
37 # if BOOST_WORKAROUND(__GNUC__, == 4) && __GNUC_MINOR__ == 0 && __GNUC_PATCHLEVEL__ == 2
38   
39 }
40
41 namespace is_incrementable_2
42 {
43   is_incrementable_::tag operator++(is_incrementable_::any const&);
44   is_incrementable_::tag operator++(is_incrementable_::any const&,int);
45 }
46 using namespace is_incrementable_2;
47
48 namespace is_incrementable_
49 {
50   
51 # else
52   
53   tag operator++(any const&);
54   tag operator++(any const&,int);
55   
56 # endif 
57
58 # if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202)) 
59 #  define BOOST_comma(a,b) (a)
60 # else 
61   // In case an operator++ is found that returns void, we'll use ++x,0
62   tag operator,(tag,int);  
63 #  define BOOST_comma(a,b) (a,b)
64 # endif 
65
66 # if defined(BOOST_MSVC)
67 #  pragma warning(push)
68 #  pragma warning(disable:4913) // Warning about operator,
69 # endif 
70
71   // two check overloads help us identify which operator++ was picked
72   char (& check_(tag) )[2];
73   
74   template <class T>
75   char check_(T const&);
76   
77
78   template <class T>
79   struct impl
80   {
81       static typename boost::remove_cv<T>::type& x;
82
83       BOOST_STATIC_CONSTANT(
84           bool
85         , value = sizeof(is_incrementable_::check_(BOOST_comma(++x,0))) == 1
86       );
87   };
88
89   template <class T>
90   struct postfix_impl
91   {
92       static typename boost::remove_cv<T>::type& x;
93
94       BOOST_STATIC_CONSTANT(
95           bool
96         , value = sizeof(is_incrementable_::check_(BOOST_comma(x++,0))) == 1
97       );
98   };
99
100 # if defined(BOOST_MSVC)
101 #  pragma warning(pop)
102 # endif 
103
104 }
105
106 # undef BOOST_comma
107
108 template<typename T> 
109 struct is_incrementable 
110 BOOST_TT_AUX_BOOL_C_BASE(::boost::detail::is_incrementable_::impl<T>::value)
111
112     BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(::boost::detail::is_incrementable_::impl<T>::value)
113     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_incrementable,(T))
114 };
115
116 template<typename T> 
117 struct is_postfix_incrementable 
118 BOOST_TT_AUX_BOOL_C_BASE(::boost::detail::is_incrementable_::postfix_impl<T>::value)
119
120     BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(::boost::detail::is_incrementable_::postfix_impl<T>::value)
121     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_postfix_incrementable,(T))
122 };
123
124 } // namespace detail
125
126 BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1, ::boost::detail::is_incrementable)
127 BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1, ::boost::detail::is_postfix_incrementable)
128
129 } // namespace boost
130
131 # include <boost/type_traits/detail/bool_trait_undef.hpp>
132
133 #endif // IS_INCREMENTABLE_DWA200415_HPP