fix doc example typo
[boost.git] / boost / pointee.hpp
blob9794b8e7dbeb63f1401b479c835c6429cbfb08b4
1 #ifndef POINTEE_DWA200415_HPP
2 # define POINTEE_DWA200415_HPP
4 //
5 // Copyright David Abrahams 2004. Use, modification and distribution is
6 // subject to the Boost Software License, Version 1.0. (See accompanying
7 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 //
9 // typename pointee<P>::type provides the pointee type of P.
11 // For example, it is T for T* and X for shared_ptr<X>.
13 // http://www.boost.org/libs/iterator/doc/pointee.html
16 # include <boost/detail/is_incrementable.hpp>
17 # include <boost/iterator/iterator_traits.hpp>
18 # include <boost/type_traits/add_const.hpp>
19 # include <boost/type_traits/remove_cv.hpp>
20 # include <boost/mpl/if.hpp>
21 # include <boost/mpl/eval_if.hpp>
23 namespace boost {
25 namespace detail
27 template <class P>
28 struct smart_ptr_pointee
30 typedef typename P::element_type type;
33 template <class Iterator>
34 struct iterator_pointee
36 typedef typename iterator_traits<Iterator>::value_type value_type;
38 struct impl
40 template <class T>
41 static char test(T const&);
43 static char (& test(value_type&) )[2];
45 static Iterator& x;
48 BOOST_STATIC_CONSTANT(bool, is_constant = sizeof(impl::test(*impl::x)) == 1);
50 typedef typename mpl::if_c<
51 # if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
52 ::boost::detail::iterator_pointee<Iterator>::is_constant
53 # else
54 is_constant
55 # endif
56 , typename add_const<value_type>::type
57 , value_type
58 >::type type;
62 template <class P>
63 struct pointee
64 : mpl::eval_if<
65 detail::is_incrementable<P>
66 , detail::iterator_pointee<P>
67 , detail::smart_ptr_pointee<P>
72 } // namespace boost
74 #endif // POINTEE_DWA200415_HPP