c++ - Is there a way to prevent a class from being derived from twice using a static assert and type trait? -
c++ - Is there a way to prevent a class from being derived from twice using a static assert and type trait? -
i realize contrived example, want compile check prevent this...
class {}; class b : public {}; class c : public {}; class d : public b, public c { boost_static_assert((is_base_of_once<a,d>::value)) };
the next should work:
boost_static_assert(((a*)(d*)0 == 0))
if exists twice, should rising ambiguity error, while otherwise test succeed (because compares 2 null pointers).
c++ multiple-inheritance typetraits static-assert
Comments
Post a Comment