From a8d6f40794fee484ec07f1d13c2514a687889779 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 15 Mar 2002 14:16:31 +0000 Subject: [PATCH] *** empty log message *** [SVN r13210] --- .../python/detail/member_function_cast.hpp | 14 ++++- include/boost/python/detail/wrap_function.hpp | 5 ++ src/object/inheritance.cpp | 2 +- test/Jamfile | 7 ++- test/member_function_cast.cpp | 55 +++++++++++++++++++ test/module_tail.cpp | 3 + 6 files changed, 80 insertions(+), 6 deletions(-) create mode 100644 test/member_function_cast.cpp diff --git a/include/boost/python/detail/member_function_cast.hpp b/include/boost/python/detail/member_function_cast.hpp index 52718390..6e3f18c4 100644 --- a/include/boost/python/detail/member_function_cast.hpp +++ b/include/boost/python/detail/member_function_cast.hpp @@ -43,6 +43,13 @@ struct non_member_function_cast_impl template struct member_function_cast_impl { +# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template + static non_member_function_cast_impl stage1(U) + { + return non_member_function_cast_impl(); + } +# endif template static cast_helper stage1(R (S::*)()) { @@ -85,7 +92,6 @@ struct member_function_cast_impl return cast_helper(); } -# if 1 template static cast_helper stage1(R (S::*)()const) { @@ -170,7 +176,6 @@ struct member_function_cast_impl return cast_helper(); } -// # ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template static cast_helper stage1(R (S::*)()const volatile) { @@ -212,17 +217,20 @@ struct member_function_cast_impl { return cast_helper(); } -# endif }; template struct member_function_cast +# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + : member_function_cast_impl +# else : mpl::select_type< is_member_function_pointer::value , member_function_cast_impl , non_member_function_cast_impl >::type +# endif { }; diff --git a/include/boost/python/detail/wrap_function.hpp b/include/boost/python/detail/wrap_function.hpp index 0424183d..682b3e89 100644 --- a/include/boost/python/detail/wrap_function.hpp +++ b/include/boost/python/detail/wrap_function.hpp @@ -45,9 +45,14 @@ template PyObject* wrap_function(F f) { return wrap_function_select< +# if 1 + type_traits::ice_not< + is_pointer::value +# else type_traits::ice_or< is_function::value , is_member_function_pointer::value +# endif >::value >::execute(f); } diff --git a/src/object/inheritance.cpp b/src/object/inheritance.cpp index 5b95e478..91a37f02 100644 --- a/src/object/inheritance.cpp +++ b/src/object/inheritance.cpp @@ -109,7 +109,7 @@ namespace make_iterator_property_map( to_target , get(vertex_index, reverse_topology) -# ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +# ifdef BOOST_NO_STD_ITERATOR_TRAITS , *to_target # endif ) diff --git a/test/Jamfile b/test/Jamfile index 1f5de1e9..a01efdde 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -59,11 +59,14 @@ bpl-test virtual_functions ; # --- unit tests of library components --- unit-test indirect_traits_test - : indirect_traits_test.cpp : $(BOOST_ROOT) ; + : indirect_traits_test.cpp : $(BOOST_ROOT) ; unit-test destroy_test : destroy_test.cpp : $(BOOST_ROOT) ; unit-test pointer_type_id_test - : pointer_type_id_test.cpp : $(BOOST_ROOT) ; + : pointer_type_id_test.cpp : $(BOOST_ROOT) ; + +unit-test member_function_cast + : member_function_cast.cpp : $(BOOST_ROOT) ; unit-test select_from_python_test : select_from_python_test.cpp diff --git a/test/member_function_cast.cpp b/test/member_function_cast.cpp new file mode 100644 index 00000000..986d87b5 --- /dev/null +++ b/test/member_function_cast.cpp @@ -0,0 +1,55 @@ +// 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. +#include +#include +#include +#include + +using namespace boost; + +template +void assert_same(S, type* = 0) +{ + BOOST_STATIC_ASSERT((is_same::value)); +} + +template +void assert_mf_cast(F f, type* = 0, type* = 0) +{ + assert_same( + python::detail::member_function_cast::stage1(f).stage2((Target*)0).stage3(f) + ); +} + +struct X +{ + int f() const { return 0; } + void g(char*) {} +}; + +struct Y : X +{ + +}; + +struct Z : Y +{ + int f() const { return 0; } + void g(char*) {} +}; + +int main() +{ + assert_mf_cast(&X::f); + assert_mf_cast(&X::g); + + assert_mf_cast(&Z::f); + assert_mf_cast(&Z::g); + + assert_mf_cast(3); + assert_mf_cast(X()); + return 0; +}; diff --git a/test/module_tail.cpp b/test/module_tail.cpp index 6849bf83..763e7dff 100644 --- a/test/module_tail.cpp +++ b/test/module_tail.cpp @@ -16,10 +16,13 @@ extern "C" BOOL WINAPI DllMain ( HINSTANCE hInst, DWORD wDataSeg, LPVOID lpvReserved ); # ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable:4297) extern "C" void structured_exception_translator(unsigned int, EXCEPTION_POINTERS*) { throw; } +# pragma warning(pop) # endif BOOL WINAPI DllMain(