Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:42

0001 // Copyright David Abrahams 2004. Use, modification and distribution is
0002 // subject to the Boost Software License, Version 1.0. (See accompanying
0003 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0004 #ifndef IS_INCREMENTABLE_DWA200415_HPP
0005 # define IS_INCREMENTABLE_DWA200415_HPP
0006 
0007 # include <boost/type_traits/integral_constant.hpp>
0008 # include <boost/type_traits/remove_cv.hpp>
0009 # include <boost/detail/workaround.hpp>
0010 
0011 namespace boost { namespace detail {
0012 
0013 // is_incrementable<T> metafunction
0014 //
0015 // Requires: Given x of type T&, if the expression ++x is well-formed
0016 // it must have complete type; otherwise, it must neither be ambiguous
0017 // nor violate access.
0018 
0019 // This namespace ensures that ADL doesn't mess things up.
0020 namespace is_incrementable_
0021 {
0022   // a type returned from operator++ when no increment is found in the
0023   // type's own namespace
0024   struct tag {};
0025 
0026   // any soaks up implicit conversions and makes the following
0027   // operator++ less-preferred than any other such operator that
0028   // might be found via ADL.
0029   struct any { template <class T> any(T const&); };
0030 
0031   // This is a last-resort operator++ for when none other is found
0032 # if BOOST_WORKAROUND(__GNUC__, == 4) && __GNUC_MINOR__ == 0 && __GNUC_PATCHLEVEL__ == 2
0033 
0034 }
0035 
0036 namespace is_incrementable_2
0037 {
0038   is_incrementable_::tag operator++(is_incrementable_::any const&);
0039   is_incrementable_::tag operator++(is_incrementable_::any const&,int);
0040 }
0041 using namespace is_incrementable_2;
0042 
0043 namespace is_incrementable_
0044 {
0045 
0046 # else
0047 
0048   tag operator++(any const&);
0049   tag operator++(any const&,int);
0050 
0051 # endif
0052 
0053 # if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202)) 
0054 #  define BOOST_comma(a,b) (a)
0055 # else
0056   // In case an operator++ is found that returns void, we'll use ++x,0
0057   tag operator,(tag,int);
0058 #  define BOOST_comma(a,b) (a,b)
0059 # endif
0060 
0061 # if defined(BOOST_MSVC)
0062 #  pragma warning(push)
0063 #  pragma warning(disable:4913) // Warning about operator,
0064 # endif
0065 
0066   // two check overloads help us identify which operator++ was picked
0067   char (& check_(tag) )[2];
0068 
0069   template <class T>
0070   char check_(T const&);
0071 
0072 
0073   template <class T>
0074   struct impl
0075   {
0076       static typename boost::remove_cv<T>::type& x;
0077 
0078       BOOST_STATIC_CONSTANT(
0079           bool
0080         , value = sizeof(is_incrementable_::check_(BOOST_comma(++x,0))) == 1
0081       );
0082   };
0083 
0084   template <class T>
0085   struct postfix_impl
0086   {
0087       static typename boost::remove_cv<T>::type& x;
0088 
0089       BOOST_STATIC_CONSTANT(
0090           bool
0091         , value = sizeof(is_incrementable_::check_(BOOST_comma(x++,0))) == 1
0092       );
0093   };
0094 
0095 # if defined(BOOST_MSVC)
0096 #  pragma warning(pop)
0097 # endif
0098 
0099 }
0100 
0101 # undef BOOST_comma
0102 
0103 template<typename T>
0104 struct is_incrementable :
0105     public boost::integral_constant<bool, boost::detail::is_incrementable_::impl<T>::value>
0106 {
0107 };
0108 
0109 template<typename T>
0110 struct is_postfix_incrementable :
0111     public boost::integral_constant<bool, boost::detail::is_incrementable_::postfix_impl<T>::value>
0112 {
0113 };
0114 
0115 } // namespace detail
0116 
0117 } // namespace boost
0118 
0119 # include <boost/type_traits/detail/bool_trait_undef.hpp>
0120 
0121 #endif // IS_INCREMENTABLE_DWA200415_HPP