Test object identity with shared_ptr_converter.
[luabind.git] / luabind / detail / deduce_signature.hpp
blobe47e22f4e816929867db19022763c96162b5f1ce
1 // Copyright Daniel Wallin 2008. 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)
5 #if !BOOST_PP_IS_ITERATING
7 # ifndef LUABIND_DEDUCE_SIGNATURE_080911_HPP
8 # define LUABIND_DEDUCE_SIGNATURE_080911_HPP
10 # include <luabind/detail/most_derived.hpp>
12 # if LUABIND_MAX_ARITY <= 8
13 # include <boost/mpl/vector/vector10.hpp>
14 # else
15 # include <boost/mpl/vector/vector50.hpp>
16 # endif
17 # include <boost/preprocessor/cat.hpp>
18 # include <boost/preprocessor/iteration/iterate.hpp>
19 # include <boost/preprocessor/repetition/enum_params.hpp>
21 namespace luabind { namespace detail {
23 namespace mpl = boost::mpl;
25 template <class R>
26 mpl::vector1<R> deduce_signature(R(*)(), ...)
28 return mpl::vector1<R>();
31 template <class R, class T>
32 mpl::vector2<R,T&> deduce_signature(R(T::*)())
34 return mpl::vector2<R,T&>();
37 template <class R, class T, class Wrapped>
38 mpl::vector2<R,typename most_derived<T,Wrapped>::type&>
39 deduce_signature(R(T::*)(), Wrapped*)
41 return mpl::vector2<R,typename most_derived<T,Wrapped>::type&>();
44 template <class R, class T>
45 mpl::vector2<R,T const&> deduce_signature(R(T::*)() const)
47 return mpl::vector2<R,T const&>();
50 template <class R, class T, class Wrapped>
51 mpl::vector2<R,typename most_derived<T,Wrapped>::type const&>
52 deduce_signature(R(T::*)() const, Wrapped*)
54 return mpl::vector2<R,typename most_derived<T,Wrapped>::type const&>();
57 # define BOOST_PP_ITERATION_PARAMS_1 \
58 (3, (1, LUABIND_MAX_ARITY, <luabind/detail/deduce_signature.hpp>))
59 # include BOOST_PP_ITERATE()
61 }} // namespace luabind::detail
63 # endif // LUABIND_DEDUCE_SIGNATURE_080911_HPP
65 #else // BOOST_PP_IS_ITERATING
67 # define N BOOST_PP_ITERATION()
68 # define NPLUS1 BOOST_PP_INC(N)
70 template <class R, BOOST_PP_ENUM_PARAMS(N,class A)>
71 BOOST_PP_CAT(mpl::vector,NPLUS1)<R, BOOST_PP_ENUM_PARAMS(N,A)>
72 deduce_signature(R(*)(BOOST_PP_ENUM_PARAMS(N,A)), ...)
74 return BOOST_PP_CAT(mpl::vector,NPLUS1)<R,BOOST_PP_ENUM_PARAMS(N,A)>();
77 # define NPLUS2 BOOST_PP_INC(NPLUS1)
79 template <class R, class T, BOOST_PP_ENUM_PARAMS(N,class A)>
80 BOOST_PP_CAT(mpl::vector,NPLUS2)<R, T&, BOOST_PP_ENUM_PARAMS(N,A)>
81 deduce_signature(R(T::*)(BOOST_PP_ENUM_PARAMS(N,A)))
83 return BOOST_PP_CAT(mpl::vector,NPLUS2)<R,T&,BOOST_PP_ENUM_PARAMS(N,A)>();
86 template <class R, class T, BOOST_PP_ENUM_PARAMS(N,class A), class Wrapped>
87 BOOST_PP_CAT(mpl::vector,NPLUS2)<
88 R, typename most_derived<T,Wrapped>::type&, BOOST_PP_ENUM_PARAMS(N,A)
90 deduce_signature(R(T::*)(BOOST_PP_ENUM_PARAMS(N,A)), Wrapped*)
92 return BOOST_PP_CAT(mpl::vector,NPLUS2)<
93 R,typename most_derived<T,Wrapped>::type&,BOOST_PP_ENUM_PARAMS(N,A)>();
96 template <class R, class T, BOOST_PP_ENUM_PARAMS(N,class A)>
97 BOOST_PP_CAT(mpl::vector,NPLUS2)<R, T const&, BOOST_PP_ENUM_PARAMS(N,A)>
98 deduce_signature(R(T::*)(BOOST_PP_ENUM_PARAMS(N,A)) const)
100 return BOOST_PP_CAT(mpl::vector,NPLUS2)<R,T const&,BOOST_PP_ENUM_PARAMS(N,A)>();
103 template <class R, class T, BOOST_PP_ENUM_PARAMS(N,class A), class Wrapped>
104 BOOST_PP_CAT(mpl::vector,NPLUS2)<
105 R, typename most_derived<T,Wrapped>::type const&, BOOST_PP_ENUM_PARAMS(N,A)
107 deduce_signature(R(T::*)(BOOST_PP_ENUM_PARAMS(N,A)) const, Wrapped*)
109 return BOOST_PP_CAT(mpl::vector,NPLUS2)<
110 R,typename most_derived<T,Wrapped>::type const&,BOOST_PP_ENUM_PARAMS(N,A)>();
113 # undef NPLUS2
114 # undef NPLUS1
115 # undef N
117 #endif // BOOST_PP_IS_ITERATING