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
7 # include <boost/type_traits/remove_cv.hpp>
8 # include <boost/mpl/bool.hpp>
9 # include <boost/detail/workaround.hpp>
11 namespace boost { namespace detail {
13 // is_incrementable<T> metafunction
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.
19 // This namespace ensures that ADL doesn't mess things up.
20 namespace is_incrementable_
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&);
30 // two check overloads help us identify which operator++ was picked
31 char (& check(tag) )[2];
39 # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
45 static typename remove_cv<T>::type& x;
47 BOOST_STATIC_CONSTANT(
49 , value = sizeof(is_incrementable_::check(++x)) == 1
53 # if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
54 ::boost::detail::is_incrementable_::is_incrementable<T>::
60 # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
62 struct is_incrementable : is_incrementable_::impl<T>
66 using is_incrementable_::is_incrementable;
69 }} // namespace boost::detail
71 #endif // IS_INCREMENTABLE_DWA200415_HPP