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

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -