Skip to content

Commit ff76bbb

Browse files
authored
Merge pull request #47 from qchateau/develop
Support parameter packs for bases in BOOST_DESCRIBE_CLASS
2 parents 18e7c01 + 2e63564 commit ff76bbb

File tree

2 files changed

+32
-15
lines changed

2 files changed

+32
-15
lines changed

include/boost/describe/detail/bases.hpp

+9-15
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,18 @@ template<class C, class B> struct base_descriptor
3030
template<class C, class B> constexpr unsigned base_descriptor<C, B>::modifiers;
3131
#endif
3232

33-
template<class... T> auto base_descriptor_fn_impl( int, T... )
34-
{
35-
return list<T...>();
36-
}
37-
38-
#define BOOST_DESCRIBE_BASE_IMPL(C, B) , boost::describe::detail::base_descriptor<C, B>()
39-
40-
#if defined(_MSC_VER) && !defined(__clang__)
41-
42-
#define BOOST_DESCRIBE_BASES(C, ...) inline auto boost_base_descriptor_fn( C** ) \
43-
{ return boost::describe::detail::base_descriptor_fn_impl( 0 BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_BASE_IMPL, C, __VA_ARGS__) ); }
33+
// bases_descriptor
34+
template<typename ...>
35+
struct bases_descriptor_impl;
4436

45-
#else
37+
template<class C, class ...Bs>
38+
struct bases_descriptor_impl<C, list<Bs...>>
39+
{
40+
using type = list<base_descriptor<C, Bs>...>;
41+
};
4642

4743
#define BOOST_DESCRIBE_BASES(C, ...) inline auto boost_base_descriptor_fn( C** ) \
48-
{ return boost::describe::detail::base_descriptor_fn_impl( 0 BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_BASE_IMPL, C, ##__VA_ARGS__) ); }
49-
50-
#endif
44+
{ return typename boost::describe::detail::bases_descriptor_impl<C, boost::describe::detail::list<__VA_ARGS__>>::type(); }
5145

5246
} // namespace detail
5347
} // namespace describe

test/bases_test.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ int main() {}
6262

6363
#include <boost/mp11.hpp>
6464

65+
template<typename ...Bases>
66+
struct ZT: Bases...
67+
{
68+
BOOST_DESCRIBE_CLASS(ZT, (Bases...), (), (), ());
69+
};
70+
71+
using Z = ZT<X1, X2, X3>;
72+
6573
int main()
6674
{
6775
using namespace boost::describe;
@@ -151,6 +159,21 @@ int main()
151159
BOOST_TEST_EQ( (mp_at_c<L, 1>::modifiers), mod_private | mod_virtual );
152160
}
153161

162+
{
163+
using L = describe_bases<Z, mod_any_access>;
164+
165+
BOOST_TEST_EQ( mp_size<L>::value, 3 );
166+
167+
BOOST_TEST_TRAIT_SAME( typename mp_at_c<L, 0>::type, X1 );
168+
BOOST_TEST_EQ( (mp_at_c<L, 0>::modifiers), mod_public );
169+
170+
BOOST_TEST_TRAIT_SAME( typename mp_at_c<L, 1>::type, X2 );
171+
BOOST_TEST_EQ( (mp_at_c<L, 1>::modifiers), mod_public );
172+
173+
BOOST_TEST_TRAIT_SAME( typename mp_at_c<L, 2>::type, X3 );
174+
BOOST_TEST_EQ( (mp_at_c<L, 2>::modifiers), mod_public );
175+
}
176+
154177
return boost::report_errors();
155178
}
156179

0 commit comments

Comments
 (0)