epoc32/include/stdapis/boost/pointee.hpp
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/boost/pointee.hpp	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,74 @@
     1.4 +#ifndef POINTEE_DWA200415_HPP
     1.5 +# define POINTEE_DWA200415_HPP
     1.6 +
     1.7 +//
     1.8 +// Copyright David Abrahams 2004. Use, modification and distribution is
     1.9 +// subject to the Boost Software License, Version 1.0. (See accompanying
    1.10 +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
    1.11 +//
    1.12 +// typename pointee<P>::type provides the pointee type of P.
    1.13 +//
    1.14 +// For example, it is T for T* and X for shared_ptr<X>.
    1.15 +//
    1.16 +// http://www.boost.org/libs/iterator/doc/pointee.html
    1.17 +//
    1.18 +
    1.19 +# include <boost/detail/is_incrementable.hpp>
    1.20 +# include <boost/iterator/iterator_traits.hpp>
    1.21 +# include <boost/type_traits/add_const.hpp>
    1.22 +# include <boost/type_traits/remove_cv.hpp>
    1.23 +# include <boost/mpl/if.hpp>
    1.24 +# include <boost/mpl/eval_if.hpp>
    1.25 +
    1.26 +namespace boost { 
    1.27 +
    1.28 +namespace detail
    1.29 +{
    1.30 +  template <class P>
    1.31 +  struct smart_ptr_pointee
    1.32 +  {
    1.33 +      typedef typename P::element_type type;
    1.34 +  };
    1.35 +
    1.36 +  template <class Iterator>
    1.37 +  struct iterator_pointee
    1.38 +  {
    1.39 +      typedef typename iterator_traits<Iterator>::value_type value_type;
    1.40 +      
    1.41 +      struct impl
    1.42 +      {
    1.43 +          template <class T>
    1.44 +          static char test(T const&);
    1.45 +          
    1.46 +          static char (& test(value_type&) )[2];
    1.47 +          
    1.48 +          static Iterator& x;
    1.49 +      };
    1.50 +      
    1.51 +      BOOST_STATIC_CONSTANT(bool, is_constant = sizeof(impl::test(*impl::x)) == 1);
    1.52 +      
    1.53 +      typedef typename mpl::if_c<
    1.54 +#  if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
    1.55 +          ::boost::detail::iterator_pointee<Iterator>::is_constant
    1.56 +#  else
    1.57 +          is_constant
    1.58 +#  endif 
    1.59 +        , typename add_const<value_type>::type
    1.60 +        , value_type
    1.61 +      >::type type;
    1.62 +  };
    1.63 +}
    1.64 +
    1.65 +template <class P>
    1.66 +struct pointee
    1.67 +  : mpl::eval_if<
    1.68 +        detail::is_incrementable<P>
    1.69 +      , detail::iterator_pointee<P>
    1.70 +      , detail::smart_ptr_pointee<P>
    1.71 +    >
    1.72 +{
    1.73 +};
    1.74 +  
    1.75 +} // namespace boost
    1.76 +
    1.77 +#endif // POINTEE_DWA200415_HPP