Skip to content

Commit a8d6f40

Browse files
committed
*** empty log message ***
[SVN r13210]
1 parent a2071fe commit a8d6f40

File tree

6 files changed

+80
-6
lines changed

6 files changed

+80
-6
lines changed

include/boost/python/detail/member_function_cast.hpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ struct non_member_function_cast_impl
4343
template <class T>
4444
struct member_function_cast_impl
4545
{
46+
# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
47+
template <class U>
48+
static non_member_function_cast_impl stage1(U)
49+
{
50+
return non_member_function_cast_impl();
51+
}
52+
# endif
4653
template <class S, class R>
4754
static cast_helper<S,R(T::*)()> stage1(R (S::*)())
4855
{
@@ -85,7 +92,6 @@ struct member_function_cast_impl
8592
return cast_helper<S,R(T::*)(A0,A1,A2,A3,A4,A5)>();
8693
}
8794

88-
# if 1
8995
template <class S, class R>
9096
static cast_helper<S,R(T::*)()const> stage1(R (S::*)()const)
9197
{
@@ -170,7 +176,6 @@ struct member_function_cast_impl
170176
return cast_helper<S,R(T::*)(A0,A1,A2,A3,A4,A5)volatile>();
171177
}
172178

173-
// # ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
174179
template <class S, class R>
175180
static cast_helper<S,R(T::*)()const volatile> stage1(R (S::*)()const volatile)
176181
{
@@ -212,17 +217,20 @@ struct member_function_cast_impl
212217
{
213218
return cast_helper<S,R(T::*)(A0,A1,A2,A3,A4,A5)const volatile>();
214219
}
215-
# endif
216220
};
217221

218222

219223
template <class T, class SF>
220224
struct member_function_cast
225+
# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
226+
: member_function_cast_impl<T>
227+
# else
221228
: mpl::select_type<
222229
is_member_function_pointer<SF>::value
223230
, member_function_cast_impl<T>
224231
, non_member_function_cast_impl
225232
>::type
233+
# endif
226234
{
227235
};
228236

include/boost/python/detail/wrap_function.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,14 @@ template <class F>
4545
PyObject* wrap_function(F f)
4646
{
4747
return wrap_function_select<
48+
# if 1
49+
type_traits::ice_not<
50+
is_pointer<F>::value
51+
# else
4852
type_traits::ice_or<
4953
is_function<F>::value
5054
, is_member_function_pointer<F>::value
55+
# endif
5156
>::value >::execute(f);
5257
}
5358

src/object/inheritance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ namespace
109109
make_iterator_property_map(
110110
to_target
111111
, get(vertex_index, reverse_topology)
112-
# ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
112+
# ifdef BOOST_NO_STD_ITERATOR_TRAITS
113113
, *to_target
114114
# endif
115115
)

test/Jamfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,14 @@ bpl-test virtual_functions ;
5959

6060
# --- unit tests of library components ---
6161
unit-test indirect_traits_test
62-
: indirect_traits_test.cpp : <include>$(BOOST_ROOT) ;
62+
: indirect_traits_test.cpp : <include>$(BOOST_ROOT) ;
6363
unit-test destroy_test
6464
: destroy_test.cpp : <include>$(BOOST_ROOT) ;
6565
unit-test pointer_type_id_test
66-
: pointer_type_id_test.cpp : <include>$(BOOST_ROOT) ;
66+
: pointer_type_id_test.cpp : <include>$(BOOST_ROOT) ;
67+
68+
unit-test member_function_cast
69+
: member_function_cast.cpp : <include>$(BOOST_ROOT) ;
6770

6871
unit-test select_from_python_test
6972
: select_from_python_test.cpp

test/member_function_cast.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Copyright David Abrahams 2002. Permission to copy, use,
2+
// modify, sell and distribute this software is granted provided this
3+
// copyright notice appears in all copies. This software is provided
4+
// "as is" without express or implied warranty, and with no claim as
5+
// to its suitability for any purpose.
6+
#include <boost/python/detail/member_function_cast.hpp>
7+
#include <boost/type_traits.hpp>
8+
#include <boost/type.hpp>
9+
#include <boost/static_assert.hpp>
10+
11+
using namespace boost;
12+
13+
template <class T, class S>
14+
void assert_same(S, type<T>* = 0)
15+
{
16+
BOOST_STATIC_ASSERT((is_same<T,S>::value));
17+
}
18+
19+
template <class Expected, class Target, class F>
20+
void assert_mf_cast(F f, type<Expected>* = 0, type<Target>* = 0)
21+
{
22+
assert_same<Expected>(
23+
python::detail::member_function_cast<Target,F>::stage1(f).stage2((Target*)0).stage3(f)
24+
);
25+
}
26+
27+
struct X
28+
{
29+
int f() const { return 0; }
30+
void g(char*) {}
31+
};
32+
33+
struct Y : X
34+
{
35+
36+
};
37+
38+
struct Z : Y
39+
{
40+
int f() const { return 0; }
41+
void g(char*) {}
42+
};
43+
44+
int main()
45+
{
46+
assert_mf_cast<int (Y::*)() const, Y>(&X::f);
47+
assert_mf_cast<void (Y::*)(char*), Y>(&X::g);
48+
49+
assert_mf_cast<int (Z::*)() const, Y>(&Z::f);
50+
assert_mf_cast<void (Z::*)(char*), Y>(&Z::g);
51+
52+
assert_mf_cast<int, Y>(3);
53+
assert_mf_cast<X, Y>(X());
54+
return 0;
55+
};

test/module_tail.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@
1616
extern "C" BOOL WINAPI DllMain ( HINSTANCE hInst, DWORD wDataSeg, LPVOID lpvReserved );
1717

1818
# ifdef BOOST_MSVC
19+
# pragma warning(push)
20+
# pragma warning(disable:4297)
1921
extern "C" void structured_exception_translator(unsigned int, EXCEPTION_POINTERS*)
2022
{
2123
throw;
2224
}
25+
# pragma warning(pop)
2326
# endif
2427

2528
BOOL WINAPI DllMain(

0 commit comments

Comments
 (0)