mirror of
https://github.com/boostorg/describe.git
synced 2026-01-19 04:12:07 +00:00
Support parameter packs for bases in BOOST_DESCRIBE_CLASS
This commit is contained in:
@@ -30,24 +30,18 @@ template<class C, class B> struct base_descriptor
|
||||
template<class C, class B> constexpr unsigned base_descriptor<C, B>::modifiers;
|
||||
#endif
|
||||
|
||||
template<class... T> auto base_descriptor_fn_impl( int, T... )
|
||||
// bases_descriptor
|
||||
template<typename ...>
|
||||
struct bases_descriptor_impl;
|
||||
|
||||
template<class C, class ...Bs>
|
||||
struct bases_descriptor_impl<C, list<Bs...>>
|
||||
{
|
||||
return list<T...>();
|
||||
}
|
||||
|
||||
#define BOOST_DESCRIBE_BASE_IMPL(C, B) , boost::describe::detail::base_descriptor<C, B>()
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
using type = list<base_descriptor<C, Bs>...>;
|
||||
};
|
||||
|
||||
#define BOOST_DESCRIBE_BASES(C, ...) inline auto boost_base_descriptor_fn( C** ) \
|
||||
{ return boost::describe::detail::base_descriptor_fn_impl( 0 BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_BASE_IMPL, C, __VA_ARGS__) ); }
|
||||
|
||||
#else
|
||||
|
||||
#define BOOST_DESCRIBE_BASES(C, ...) inline auto boost_base_descriptor_fn( C** ) \
|
||||
{ return boost::describe::detail::base_descriptor_fn_impl( 0 BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_BASE_IMPL, C, ##__VA_ARGS__) ); }
|
||||
|
||||
#endif
|
||||
{ return typename boost::describe::detail::bases_descriptor_impl<C, boost::describe::detail::list<__VA_ARGS__>>::type(); }
|
||||
|
||||
} // namespace detail
|
||||
} // namespace describe
|
||||
|
||||
@@ -62,6 +62,14 @@ int main() {}
|
||||
|
||||
#include <boost/mp11.hpp>
|
||||
|
||||
template<typename ...Bases>
|
||||
struct ZT: Bases...
|
||||
{
|
||||
BOOST_DESCRIBE_CLASS(ZT, (Bases...), (), (), ());
|
||||
};
|
||||
|
||||
using Z = ZT<X1, X2, X3>;
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::describe;
|
||||
@@ -151,6 +159,21 @@ int main()
|
||||
BOOST_TEST_EQ( (mp_at_c<L, 1>::modifiers), mod_private | mod_virtual );
|
||||
}
|
||||
|
||||
{
|
||||
using L = describe_bases<Z, mod_any_access>;
|
||||
|
||||
BOOST_TEST_EQ( mp_size<L>::value, 3 );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( typename mp_at_c<L, 0>::type, X1 );
|
||||
BOOST_TEST_EQ( (mp_at_c<L, 0>::modifiers), mod_public );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( typename mp_at_c<L, 1>::type, X2 );
|
||||
BOOST_TEST_EQ( (mp_at_c<L, 1>::modifiers), mod_public );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( typename mp_at_c<L, 2>::type, X3 );
|
||||
BOOST_TEST_EQ( (mp_at_c<L, 2>::modifiers), mod_public );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user