I'm experimenting with C++11, constexpr and auto.
I'm failing to understand why this code does not compile:
template<class T, T t>
struct TestEle2
{
};
template<class T, T t>
struct DStruct {int a;};
template<char t>
struct TestEle2<char, t>
{
static constexpr auto f = std::make_tuple(222/*
&DStruct<char, t>::a*/);
static constexpr auto g = std::make_tuple(&DStruct<char, t>::a);
};
template<char c>
constexpr decltype(TestEle2<char, c>::f)
TestEle2<char, c>::f ; // This compiles
template<char c>
constexpr decltype(TestEle2<char, c>::f)
TestEle2<char, c>::g ; // This does not compile
Without definition I have linking problems. I know this problem has been fixed in C++17 but better understand fully C++11 now
Aucun commentaire:
Enregistrer un commentaire