sl@0: // Copyright David Abrahams 2004. Use, modification and distribution is sl@0: // subject to the Boost Software License, Version 1.0. (See accompanying sl@0: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) sl@0: #ifndef IS_INCREMENTABLE_DWA200415_HPP sl@0: # define IS_INCREMENTABLE_DWA200415_HPP sl@0: sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: sl@0: // Must be the last include sl@0: # include sl@0: sl@0: namespace boost { namespace detail { sl@0: sl@0: // is_incrementable metafunction sl@0: // sl@0: // Requires: Given x of type T&, if the expression ++x is well-formed sl@0: // it must have complete type; otherwise, it must neither be ambiguous sl@0: // nor violate access. sl@0: sl@0: // This namespace ensures that ADL doesn't mess things up. sl@0: namespace is_incrementable_ sl@0: { sl@0: // a type returned from operator++ when no increment is found in the sl@0: // type's own namespace sl@0: struct tag {}; sl@0: sl@0: // any soaks up implicit conversions and makes the following sl@0: // operator++ less-preferred than any other such operator that sl@0: // might be found via ADL. sl@0: struct any { template any(T const&); }; sl@0: sl@0: // This is a last-resort operator++ for when none other is found sl@0: # if BOOST_WORKAROUND(__GNUC__, == 4) && __GNUC_MINOR__ == 0 && __GNUC_PATCHLEVEL__ == 2 sl@0: sl@0: } sl@0: sl@0: namespace is_incrementable_2 sl@0: { sl@0: is_incrementable_::tag operator++(is_incrementable_::any const&); sl@0: is_incrementable_::tag operator++(is_incrementable_::any const&,int); sl@0: } sl@0: using namespace is_incrementable_2; sl@0: sl@0: namespace is_incrementable_ sl@0: { sl@0: sl@0: # else sl@0: sl@0: tag operator++(any const&); sl@0: tag operator++(any const&,int); sl@0: sl@0: # endif sl@0: sl@0: # if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202)) \ sl@0: || BOOST_WORKAROUND(BOOST_MSVC, <= 1300) sl@0: # define BOOST_comma(a,b) (a) sl@0: # else sl@0: // In case an operator++ is found that returns void, we'll use ++x,0 sl@0: tag operator,(tag,int); sl@0: # define BOOST_comma(a,b) (a,b) sl@0: # endif sl@0: sl@0: // two check overloads help us identify which operator++ was picked sl@0: char (& check(tag) )[2]; sl@0: sl@0: template sl@0: char check(T const&); sl@0: sl@0: sl@0: template sl@0: struct impl sl@0: { sl@0: static typename boost::remove_cv::type& x; sl@0: sl@0: BOOST_STATIC_CONSTANT( sl@0: bool sl@0: , value = sizeof(is_incrementable_::check(BOOST_comma(++x,0))) == 1 sl@0: ); sl@0: }; sl@0: sl@0: template sl@0: struct postfix_impl sl@0: { sl@0: static typename boost::remove_cv::type& x; sl@0: sl@0: BOOST_STATIC_CONSTANT( sl@0: bool sl@0: , value = sizeof(is_incrementable_::check(BOOST_comma(x++,0))) == 1 sl@0: ); sl@0: }; sl@0: } sl@0: sl@0: # undef BOOST_comma sl@0: sl@0: template sl@0: struct is_incrementable sl@0: BOOST_TT_AUX_BOOL_C_BASE(::boost::detail::is_incrementable_::impl::value) sl@0: { sl@0: BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(::boost::detail::is_incrementable_::impl::value) sl@0: BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_incrementable,(T)) sl@0: }; sl@0: sl@0: template sl@0: struct is_postfix_incrementable sl@0: BOOST_TT_AUX_BOOL_C_BASE(::boost::detail::is_incrementable_::impl::value) sl@0: { sl@0: BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(::boost::detail::is_incrementable_::postfix_impl::value) sl@0: BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_postfix_incrementable,(T)) sl@0: }; sl@0: sl@0: } // namespace detail sl@0: sl@0: BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1, ::boost::detail::is_incrementable) sl@0: BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1, ::boost::detail::is_postfix_incrementable) sl@0: sl@0: } // namespace boost sl@0: sl@0: # include sl@0: sl@0: #endif // IS_INCREMENTABLE_DWA200415_HPP