]> AND Private Git Repository - canny.git/blob - stc/exp/ml_stc_linux_make_v1.0/include/boost/detail/is_incrementable.hpp
Logo AND Algorithmique Numérique Distribuée

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