Skip to content

Commit

Permalink
Add std_shared_ptr_converter.hpp.
Browse files Browse the repository at this point in the history
Include this file if you want to use std::shared_ptr with luabind. Although
it's quite hacky, it seems to work with at least VC11 and the g++ included in
Ubuntu 12.10.
  • Loading branch information
Oberon00 committed Jun 11, 2013
1 parent 00f57e4 commit 118f808
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions luabind/std_shared_ptr_converter.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#ifndef STD_SHAREDPTR_CONVERTER_HPP_INCLUDED
#define STD_SHAREDPTR_CONVERTER_HPP_INCLUDED STD_SHAREDPTR_CONVERTER_HPP_INCLUDED

#include <boost/version.hpp>

#if BOOST_VERSION >= 105300
#include <boost/get_pointer.hpp>


namespace luabind { namespace detail { namespace has_get_pointer_ {
template<class T>
struct impl<std::shared_ptr<T>> {
BOOST_STATIC_CONSTANT(bool, value = true);
typedef boost::mpl::bool_<value> type;
};

template<class T>
struct impl<const std::shared_ptr<T>>: impl<std::shared_ptr<T>> { };

template<class T>
struct impl<volatile std::shared_ptr<T>>: impl<std::shared_ptr<T>> { };

template<class T>
struct impl<const volatile std::shared_ptr<T>>: impl<std::shared_ptr<T>> { };
}}
using boost::get_pointer;
}



#else // if BOOST_VERSION < 105300

// Not standard conforming: add function to ::std(::tr1)
namespace std {

#if defined(_MSC_VER) && _MSC_VER < 1700
namespace tr1 {
#endif

template<class T>
T * get_pointer(shared_ptr<T> const& p) { return p.get(); }

#if defined(_MSC_VER) && _MSC_VER < 1700
} // namespace tr1
#endif

} // namespace std

#endif // if BOOST_VERSION < 105300

#endif

0 comments on commit 118f808

Please sign in to comment.