]> git.lyx.org Git - lyx.git/blob - boost/boost/pointee.hpp
Boost 1.31.0
[lyx.git] / boost / boost / pointee.hpp
1 // Copyright David Abrahams 2004. Use, modification and distribution is
2 // subject to the Boost Software License, Version 1.0. (See accompanying
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4 #ifndef POINTEE_DWA200415_HPP
5 # define POINTEE_DWA200415_HPP
6
7 // dereferenceable_traits provides access to the value_type and
8 // reference of a Dereferenceable type.
9
10 # include <boost/detail/is_incrementable.hpp>
11 # include <boost/iterator/iterator_traits.hpp>
12 # include <boost/type_traits/add_const.hpp>
13 # include <boost/type_traits/remove_cv.hpp>
14 # include <boost/mpl/if.hpp>
15 # include <boost/mpl/apply_if.hpp>
16
17 namespace boost { 
18
19 namespace detail
20 {
21   template <class P>
22   struct smart_ptr_pointee
23   {
24       typedef typename P::element_type type;
25   };
26
27   template <class Iterator>
28   struct iterator_pointee
29   {
30       typedef typename iterator_traits<Iterator>::value_type value_type;
31       
32       struct impl
33       {
34           template <class T>
35           static char test(T const&);
36           
37           static char (& test(value_type&) )[2];
38           
39           static Iterator& x;
40       };
41       
42       BOOST_STATIC_CONSTANT(bool, is_constant = sizeof(impl::test(*impl::x)) == 1);
43       
44       typedef typename mpl::if_c<
45 #  if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
46           ::boost::detail::iterator_pointee<Iterator>::is_constant
47 #  else
48           is_constant
49 #  endif 
50         , typename add_const<value_type>::type
51         , value_type
52       >::type type;
53   };
54 }
55
56 template <class P>
57 struct pointee
58   : mpl::apply_if<
59         detail::is_incrementable<P>
60       , detail::iterator_pointee<P>
61       , detail::smart_ptr_pointee<P>
62     >
63 {
64 };
65   
66 } // namespace boost
67
68 #endif // POINTEE_DWA200415_HPP