]> git.lyx.org Git - lyx.git/blob - boost/boost/detail/is_incrementable.hpp
Boost 1.31.0
[lyx.git] / 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/remove_cv.hpp>
8 # include <boost/mpl/bool.hpp>
9 # include <boost/detail/workaround.hpp>
10
11 namespace boost { namespace detail { 
12
13 // is_incrementable<T> metafunction
14 //
15 // Requires: Given x of type T&, if the expression ++x is well-formed
16 // it must have complete type; otherwise, it must neither be ambiguous
17 // nor violate access.
18
19 // This namespace ensures that ADL doesn't mess things up.
20 namespace is_incrementable_
21 {
22   struct tag {};
23
24   // any soaks up implicit conversions and makes the following
25   // operator++ less-preferred than any other such operator which
26   // might be found via ADL.
27   struct any { template <class T> any(T const&); };
28   tag operator++(any const&);
29
30   // two check overloads help us identify which operator++ was picked
31   char (& check(tag) )[2];
32   
33   template <class T>
34   char check(T const&);
35   
36
37   template <class T>
38   struct
39 # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
40   impl
41 # else 
42   is_incrementable
43 # endif 
44   {
45       static typename remove_cv<T>::type& x;
46
47       BOOST_STATIC_CONSTANT(
48           bool
49         , value = sizeof(is_incrementable_::check(++x)) == 1
50       );
51
52       typedef mpl::bool_<(
53 # if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
54                              ::boost::detail::is_incrementable_::is_incrementable<T>::
55 # endif 
56                              value)> type;
57   };
58 }
59
60 # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
61 template <class T>
62 struct is_incrementable : is_incrementable_::impl<T>
63 {
64 };
65 # else
66 using is_incrementable_::is_incrementable;
67 # endif 
68
69 }} // namespace boost::detail
70
71 #endif // IS_INCREMENTABLE_DWA200415_HPP