epoc32/include/stdapis/boost/detail/is_incrementable.hpp
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/boost/detail/is_incrementable.hpp	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,124 @@
     1.4 +// Copyright David Abrahams 2004. Use, modification and distribution is
     1.5 +// subject to the Boost Software License, Version 1.0. (See accompanying
     1.6 +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
     1.7 +#ifndef IS_INCREMENTABLE_DWA200415_HPP
     1.8 +# define IS_INCREMENTABLE_DWA200415_HPP
     1.9 +
    1.10 +# include <boost/type_traits/detail/template_arity_spec.hpp>
    1.11 +# include <boost/type_traits/remove_cv.hpp>
    1.12 +# include <boost/mpl/aux_/lambda_support.hpp>
    1.13 +# include <boost/mpl/bool.hpp>
    1.14 +# include <boost/detail/workaround.hpp>
    1.15 +
    1.16 +// Must be the last include
    1.17 +# include <boost/type_traits/detail/bool_trait_def.hpp>
    1.18 +
    1.19 +namespace boost { namespace detail { 
    1.20 +
    1.21 +// is_incrementable<T> metafunction
    1.22 +//
    1.23 +// Requires: Given x of type T&, if the expression ++x is well-formed
    1.24 +// it must have complete type; otherwise, it must neither be ambiguous
    1.25 +// nor violate access.
    1.26 +
    1.27 +// This namespace ensures that ADL doesn't mess things up.
    1.28 +namespace is_incrementable_
    1.29 +{
    1.30 +  // a type returned from operator++ when no increment is found in the
    1.31 +  // type's own namespace
    1.32 +  struct tag {};
    1.33 +  
    1.34 +  // any soaks up implicit conversions and makes the following
    1.35 +  // operator++ less-preferred than any other such operator that
    1.36 +  // might be found via ADL.
    1.37 +  struct any { template <class T> any(T const&); };
    1.38 +
    1.39 +  // This is a last-resort operator++ for when none other is found
    1.40 +# if BOOST_WORKAROUND(__GNUC__, == 4) && __GNUC_MINOR__ == 0 && __GNUC_PATCHLEVEL__ == 2
    1.41 +  
    1.42 +}
    1.43 +
    1.44 +namespace is_incrementable_2
    1.45 +{
    1.46 +  is_incrementable_::tag operator++(is_incrementable_::any const&);
    1.47 +  is_incrementable_::tag operator++(is_incrementable_::any const&,int);
    1.48 +}
    1.49 +using namespace is_incrementable_2;
    1.50 +
    1.51 +namespace is_incrementable_
    1.52 +{
    1.53 +  
    1.54 +# else
    1.55 +  
    1.56 +  tag operator++(any const&);
    1.57 +  tag operator++(any const&,int);
    1.58 +  
    1.59 +# endif 
    1.60 +
    1.61 +# if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202)) \
    1.62 +    || BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
    1.63 +#  define BOOST_comma(a,b) (a)
    1.64 +# else 
    1.65 +  // In case an operator++ is found that returns void, we'll use ++x,0
    1.66 +  tag operator,(tag,int);  
    1.67 +#  define BOOST_comma(a,b) (a,b)
    1.68 +# endif 
    1.69 +  
    1.70 +  // two check overloads help us identify which operator++ was picked
    1.71 +  char (& check(tag) )[2];
    1.72 +  
    1.73 +  template <class T>
    1.74 +  char check(T const&);
    1.75 +  
    1.76 +
    1.77 +  template <class T>
    1.78 +  struct impl
    1.79 +  {
    1.80 +      static typename boost::remove_cv<T>::type& x;
    1.81 +
    1.82 +      BOOST_STATIC_CONSTANT(
    1.83 +          bool
    1.84 +        , value = sizeof(is_incrementable_::check(BOOST_comma(++x,0))) == 1
    1.85 +      );
    1.86 +  };
    1.87 +
    1.88 +  template <class T>
    1.89 +  struct postfix_impl
    1.90 +  {
    1.91 +      static typename boost::remove_cv<T>::type& x;
    1.92 +
    1.93 +      BOOST_STATIC_CONSTANT(
    1.94 +          bool
    1.95 +        , value = sizeof(is_incrementable_::check(BOOST_comma(x++,0))) == 1
    1.96 +      );
    1.97 +  };
    1.98 +}
    1.99 +
   1.100 +# undef BOOST_comma
   1.101 +
   1.102 +template<typename T> 
   1.103 +struct is_incrementable 
   1.104 +BOOST_TT_AUX_BOOL_C_BASE(::boost::detail::is_incrementable_::impl<T>::value)
   1.105 +{ 
   1.106 +    BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(::boost::detail::is_incrementable_::impl<T>::value)
   1.107 +    BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_incrementable,(T))
   1.108 +};
   1.109 +
   1.110 +template<typename T> 
   1.111 +struct is_postfix_incrementable 
   1.112 +BOOST_TT_AUX_BOOL_C_BASE(::boost::detail::is_incrementable_::impl<T>::value)
   1.113 +{ 
   1.114 +    BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(::boost::detail::is_incrementable_::postfix_impl<T>::value)
   1.115 +    BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_postfix_incrementable,(T))
   1.116 +};
   1.117 +
   1.118 +} // namespace detail
   1.119 +
   1.120 +BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1, ::boost::detail::is_incrementable)
   1.121 +BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1, ::boost::detail::is_postfix_incrementable)
   1.122 +
   1.123 +} // namespace boost
   1.124 +
   1.125 +# include <boost/type_traits/detail/bool_trait_undef.hpp>
   1.126 +
   1.127 +#endif // IS_INCREMENTABLE_DWA200415_HPP