Skip to content

Commit 4d53fb9

Browse files
committed
update to defaults gen that fixes member functions with zero arguments (added a test in defaults.cpp)
[SVN r15162]
1 parent d274a83 commit 4d53fb9

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

include/boost/python/detail/defaults_gen.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ struct func_stubs_base {};
108108
#define BPL_IMPL_MEM_FUNC_WRAPPER_GEN(INDEX, DATA) \
109109
static RT BOOST_PP_CAT(func_, INDEX) \
110110
( \
111-
ClassT& obj, \
111+
ClassT& obj BOOST_PP_COMMA_IF( \
112+
BOOST_PP_ADD(BOOST_PP_TUPLE_ELEM(3, 1, DATA), INDEX)) \
112113
BOOST_PP_ENUM \
113114
( \
114115
BOOST_PP_ADD(BOOST_PP_TUPLE_ELEM(3, 1, DATA), INDEX), \

test/defaults.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ struct X {
8383
return format % make_tuple(a, b, c, d);
8484
}
8585

86+
object
87+
bar2(int a = 0, char b = 'D', std::string c = "default", double d = 0.0) const
88+
{
89+
// tests zero arg member function
90+
return format % make_tuple(a, b, c, d);
91+
}
92+
8693
object
8794
foo(int a, bool b=false) const
8895
{
@@ -111,6 +118,7 @@ struct X {
111118
};
112119

113120
BOOST_PYTHON_MEM_FUN_GENERATOR(X_bar_stubs, bar, 1, 4)
121+
BOOST_PYTHON_MEM_FUN_GENERATOR(X_bar2_stubs, bar2, 0, 4) // tests zero arg member function
114122
BOOST_PYTHON_MEM_FUN_GENERATOR(X_foo_2_stubs, foo, 1, 2)
115123
BOOST_PYTHON_MEM_FUN_GENERATOR(X_foo_3_stubs, foo, 2, 3)
116124

0 commit comments

Comments
 (0)