1 /*=============================================================================
2 Copyright (c) 2006-2007 Tobias Schwinger
4 Use modification and distribution are subject to the Boost Software
5 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt).
7 ==============================================================================*/
9 #if !defined(BOOST_FUSION_FUNCTIONAL_INVOCATION_DETAIL_THAT_PTR_HPP_INCLUDED)
10 #define BOOST_FUSION_FUNCTIONAL_INVOCATION_DETAIL_THAT_PTR_HPP_INCLUDED
12 #include <boost/fusion/support/config.hpp>
13 #include <boost/get_pointer.hpp>
14 #include <boost/utility/addressof.hpp>
15 #include <boost/type_traits/remove_reference.hpp>
17 namespace boost { namespace fusion { namespace detail
19 template <typename Wanted>
24 typedef typename remove_reference<Wanted>::type pointee;
27 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
28 static inline pointee * do_get_pointer(T &, pointee * x)
33 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
34 static inline pointee * do_get_pointer(T & x, void const *)
36 return get_pointer(x);
41 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
42 static inline pointee * get(pointee * x)
47 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
48 static inline pointee * get(pointee & x)
50 return boost::addressof(x);
54 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
55 static inline pointee * get(T & x)
57 return do_get_pointer(x, boost::addressof(x));
61 template <typename PtrOrSmartPtr> struct non_const_pointee;
63 #if defined(BOOST_MSVC) || (defined(__BORLANDC__) && !defined(BOOST_DISABLE_WIN32))
64 # define BOOST_FUSION_TRAIT_DECL __cdecl
66 # define BOOST_FUSION_TRAIT_DECL /**/
71 using boost::get_pointer;
72 void const * BOOST_FUSION_TRAIT_DECL get_pointer(...); // fallback
74 template< typename T> char const_tester(T *);
75 template< typename T> long const_tester(T const *);
77 template <typename Ptr>
78 struct non_const_pointee_impl
82 static bool const value =
83 sizeof(const_tester(get_pointer(what))) == 1;
87 template <typename PtrOrSmartPtr> struct non_const_pointee
88 : adl_barrier::non_const_pointee_impl<
90 typename remove_reference<PtrOrSmartPtr>::type >::type >
92 typedef non_const_pointee type;
93 typedef bool value_type;