Can anybody try to explain this?
template<typename T, size_t S = T::noElems()>
struct C
{
};
struct X
{
enum E { A, B, C };
static constexpr size_t noElems() { return C+1; };
};
struct K
{
C<X> cx; // this DOES compile
};
struct Y
{
struct Z
{
enum E { A, B, C };
static constexpr size_t noElems() { return C+1; };
};
C<Z, Z::C+1> cyz; // this DOES compile
C<Z> cyz; // <--- this does NOT compile
};
With the declaration of the struct
struct Y
{
struct Z
{
enum E { A, B, C };
static constexpr size_t noElems() { return C+1; };
};
C<Z, Z::C+1> cyz1; // this DOES compile
C<Z> cyz2; // <--- this does NOT compile
};
entities cyz1
and cyz2
are parsed before inline declaration of Z::noElems()
, so the definition of
static constexpr size_t noElems() { return C+1; };
is not available at the time of declaration of
C<Z> cyz2;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With