1 // Copyright Christian Neumüller 2012. 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 
5 #ifndef LUABIND_STD_SHAREDPTR_CONVERTER_HPP_INCLUDED
6 #define LUABIND_STD_SHAREDPTR_CONVERTER_HPP_INCLUDED LUABIND_STD_SHAREDPTR_CONVERTER_HPP_INCLUDED
7 
8 #include <boost/config.hpp>
9 #if defined(LUABIND_NO_STD_SHARED_PTR)    \
10     || defined(BOOST_NO_CXX11_SMART_PTR)  \
11     && !defined(BOOST_HAS_TR1_SHARED_PTR) \
12     && (!defined(BOOST_MSVC) || BOOST_MSVC < 1600)
13 #  ifndef LUABIND_NO_STD_SHARED_PTR
14 #    define LUABIND_NO_STD_SHARED_PTR
15 #  endif
16 #else
17 
18 # include <luabind/shared_ptr_converter.hpp>
19 # include <memory> // shared_ptr
20 
21 # if BOOST_VERSION >= 105300
22 #  include <luabind/detail/has_get_pointer.hpp>
23 
24 #  include <boost/get_pointer.hpp>
25 
26 namespace luabind { namespace detail { namespace has_get_pointer_ {
27   template<class T>
28   struct impl<std::shared_ptr<T>> {
29       BOOST_STATIC_CONSTANT(bool, value = true);
30       typedef boost::mpl::bool_<value> type;
31   };
32 
33   template<class T>
34   struct impl<const std::shared_ptr<T>>: impl<std::shared_ptr<T>> { };
35 
36   template<class T>
37   struct impl<volatile std::shared_ptr<T>>: impl<std::shared_ptr<T>> { };
38 
39   template<class T>
40   struct impl<const volatile std::shared_ptr<T>>: impl<std::shared_ptr<T>> { };
41 }}
42 using boost::get_pointer;
43 }
44 
45 
46 
47 # else // if BOOST_VERSION < 105300
48 
49 // Not standard conforming: add function to ::std(::tr1)
50 namespace std {
51 
52 # if defined(_MSC_VER) && _MSC_VER < 1700
53 namespace tr1 {
54 # endif
55 
56     template<class T>
get_pointer(shared_ptr<T> const & p)57     T * get_pointer(shared_ptr<T> const& p) { return p.get(); }
58 
59 # if defined(_MSC_VER) && _MSC_VER < 1700
60 } // namespace tr1
61 # endif
62 
63 } // namespace std
64 
65 #endif // if BOOST_VERSION < 105300 / else
66 
67 namespace luabind {
68     using std::get_deleter;
69 
70     template <typename T>
71     struct default_converter<std::shared_ptr<T> >:
72         detail::shared_ptr_converter<std::shared_ptr<T> > {};
73 
74     template <typename T>
75     struct default_converter<std::shared_ptr<T> const&>:
76         detail::shared_ptr_converter<std::shared_ptr<T> > {};
77 } // namespace luabind
78 
79 #endif // if smart pointers are available
80 
81 #endif // LUABIND_STD_SHAREDPTR_CONVERTER_HPP_INCLUDED
82