mardi 8 décembre 2015

Using member declaration with enable_if?

I need conditional using member declaration.

template <bool> struct B;
template <> struct B<true> { void foo(); };
template <> struct B<false> { };

template <typename T>
struct A : public B<is_default_constructible<T>::value> {
    using B<is_default_constructible<T>::value>::foo();

    void foo(int) {}
};

This obviously doesn't work, because B::foo is not defined in half the cases. How can I achieve that? To have B<>::foo() visible in A scope beside foo(int)?

Thanks for help

Aucun commentaire:

Enregistrer un commentaire