jeudi 21 avril 2022

How to check a type has constexpr constructor

To achieve what the title says, I try this:

template<typename _t, _t = _t()>
constexpr bool f()
{
    return true;
}
template<typename _t>
constexpr bool f()
{
    return false;
}

It works well for types haven't constexpr constructor. But for other types it causes a compile error with ambiguous overloads.

so how can I check?

Aucun commentaire:

Enregistrer un commentaire