diff --git a/include/boost/python/detail/member_function_cast.hpp b/include/boost/python/detail/member_function_cast.hpp new file mode 100644 index 00000000..3d965021 --- /dev/null +++ b/include/boost/python/detail/member_function_cast.hpp @@ -0,0 +1,231 @@ +// Copyright David Abrahams 2002. Permission to copy, use, +// modify, sell and distribute this software is granted provided this +// copyright notice appears in all copies. This software is provided +// "as is" without express or implied warranty, and with no claim as +// to its suitability for any purpose. +#ifndef MEMBER_FUNCTION_CAST_DWA2002311_HPP +# define MEMBER_FUNCTION_CAST_DWA2002311_HPP +# include +# include + +namespace boost { namespace python { namespace detail { + +template +struct cast_helper +{ + struct yes_helper + { + static FT stage3(FT x) { return x; } + }; + + struct no_helper + { + template + static T stage3(T x) { return x; } + }; + + static yes_helper stage2(S*) { return yes_helper(); } + static no_helper stage2(void*) { return no_helper(); } +}; + +struct non_member_function_cast_impl +{ + template + static non_member_function_cast_impl stage1(T) { return non_member_function_cast_impl(); } + + template + static non_member_function_cast_impl stage2(T) { return non_member_function_cast_impl(); } + + template + T stage3(T x) { return x; } +}; + +template +struct member_function_cast_impl +{ + template + static cast_helper stage1(R (S::*)()) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0)) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0,A1)) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0,A1,A2)) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0,A1,A2,A3)) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0,A1,A2,A3,A4)) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0,A1,A2,A3,A4,A5)) + { + return cast_helper(); + } + +# if 1 + template + static cast_helper stage1(R (S::*)()const) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0)const) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0,A1)const) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0,A1,A2)const) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0,A1,A2,A3)const) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0,A1,A2,A3,A4)const) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0,A1,A2,A3,A4,A5)const) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)()volatile) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0)volatile) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0,A1)volatile) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0,A1,A2)volatile) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0,A1,A2,A3)volatile) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0,A1,A2,A3,A4)volatile) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0,A1,A2,A3,A4,A5)volatile) + { + return cast_helper(); + } + +// # ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + template + static cast_helper stage1(R (S::*)()const volatile) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0)const volatile) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0,A1)const volatile) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0,A1,A2)const volatile) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0,A1,A2,A3)const volatile) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0,A1,A2,A3,A4)const volatile) + { + return cast_helper(); + } + + template + static cast_helper stage1(R (S::*)(A0,A1,A2,A3,A4,A5)const volatile) + { + return cast_helper(); + } +# endif +}; + + +template +struct member_function_cast + : mpl::select_type< + is_member_function_pointer::value + , member_function_cast_impl + , non_member_function_cast_impl + >::type +{ +}; + +}}} // namespace boost::python::detail + +#endif // MEMBER_FUNCTION_CAST_DWA2002311_HPP