Chris@16
|
1 /*=============================================================================
|
Chris@16
|
2 Copyright (c) 2006-2007 Tobias Schwinger
|
Chris@16
|
3
|
Chris@16
|
4 Use modification and distribution are subject to the Boost Software
|
Chris@16
|
5 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
6 http://www.boost.org/LICENSE_1_0.txt).
|
Chris@16
|
7 ==============================================================================*/
|
Chris@16
|
8
|
Chris@16
|
9 #if !defined(BOOST_FUSION_FUNCTIONAL_INVOCATION_DETAIL_THAT_PTR_HPP_INCLUDED)
|
Chris@16
|
10 #define BOOST_FUSION_FUNCTIONAL_INVOCATION_DETAIL_THAT_PTR_HPP_INCLUDED
|
Chris@16
|
11
|
Chris@101
|
12 #include <boost/fusion/support/config.hpp>
|
Chris@16
|
13 #include <boost/get_pointer.hpp>
|
Chris@16
|
14 #include <boost/utility/addressof.hpp>
|
Chris@16
|
15 #include <boost/type_traits/config.hpp>
|
Chris@16
|
16 #include <boost/type_traits/remove_reference.hpp>
|
Chris@16
|
17
|
Chris@16
|
18 namespace boost { namespace fusion { namespace detail
|
Chris@16
|
19 {
|
Chris@16
|
20 template <typename Wanted>
|
Chris@16
|
21 struct that_ptr
|
Chris@16
|
22 {
|
Chris@16
|
23 private:
|
Chris@16
|
24
|
Chris@16
|
25 typedef typename remove_reference<Wanted>::type pointee;
|
Chris@16
|
26
|
Chris@16
|
27 template <typename T>
|
Chris@101
|
28 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
29 static inline pointee * do_get_pointer(T &, pointee * x)
|
Chris@16
|
30 {
|
Chris@16
|
31 return x;
|
Chris@16
|
32 }
|
Chris@16
|
33 template <typename T>
|
Chris@101
|
34 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
35 static inline pointee * do_get_pointer(T & x, void const *)
|
Chris@16
|
36 {
|
Chris@16
|
37 return get_pointer(x);
|
Chris@16
|
38 }
|
Chris@16
|
39
|
Chris@16
|
40 public:
|
Chris@16
|
41
|
Chris@101
|
42 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
43 static inline pointee * get(pointee * x)
|
Chris@16
|
44 {
|
Chris@16
|
45 return x;
|
Chris@16
|
46 }
|
Chris@16
|
47
|
Chris@101
|
48 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
49 static inline pointee * get(pointee & x)
|
Chris@16
|
50 {
|
Chris@16
|
51 return boost::addressof(x);
|
Chris@16
|
52 }
|
Chris@16
|
53
|
Chris@101
|
54 template <typename T>
|
Chris@101
|
55 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@101
|
56 static inline pointee * get(T & x)
|
Chris@16
|
57 {
|
Chris@16
|
58 return do_get_pointer(x, boost::addressof(x));
|
Chris@16
|
59 }
|
Chris@16
|
60 };
|
Chris@16
|
61
|
Chris@16
|
62 template <typename PtrOrSmartPtr> struct non_const_pointee;
|
Chris@16
|
63
|
Chris@16
|
64 namespace adl_barrier
|
Chris@16
|
65 {
|
Chris@16
|
66 using boost::get_pointer;
|
Chris@16
|
67 void const * BOOST_TT_DECL get_pointer(...); // fallback
|
Chris@16
|
68
|
Chris@16
|
69 template< typename T> char const_tester(T *);
|
Chris@16
|
70 template< typename T> long const_tester(T const *);
|
Chris@16
|
71
|
Chris@16
|
72 template <typename Ptr>
|
Chris@16
|
73 struct non_const_pointee_impl
|
Chris@16
|
74 {
|
Chris@16
|
75 static Ptr & what;
|
Chris@16
|
76
|
Chris@16
|
77 static bool const value =
|
Chris@16
|
78 sizeof(const_tester(get_pointer(what))) == 1;
|
Chris@16
|
79 };
|
Chris@16
|
80 }
|
Chris@16
|
81
|
Chris@16
|
82 template <typename PtrOrSmartPtr> struct non_const_pointee
|
Chris@16
|
83 : adl_barrier::non_const_pointee_impl<
|
Chris@16
|
84 typename remove_cv<
|
Chris@16
|
85 typename remove_reference<PtrOrSmartPtr>::type >::type >
|
Chris@16
|
86 {
|
Chris@16
|
87 typedef non_const_pointee type;
|
Chris@16
|
88 typedef bool value_type;
|
Chris@16
|
89 };
|
Chris@16
|
90
|
Chris@16
|
91 }}}
|
Chris@16
|
92
|
Chris@16
|
93 #endif
|
Chris@16
|
94
|