I'm trying to understand how the C++11 exactly works in respect to static constexpr. As far as I have understood if you have something like:
template<class T>
struct A
{
static constexpr auto mytuple = std::make_tuple(1,2.0,3);
};
// mytuple will be used by other methods, and it might depend on T
you need to define mytuple in the .cpp file too, something like:
template<class T>
constexpr decltype( A<T>::mytuple) A<T>::mytuple;
But what if I specialize A in other files, do I need to define them again for each type? it seemed working without the definition for the specializations, but when I used it with other template functions I started having compilation / linking issues.
I know that this has been fixed in C++17 and that this is deprecated, but is there any workaround that I can use?
Aucun commentaire:
Enregistrer un commentaire