Dan Piponi on Nostr: Here's C++ playing a nasty trick on me: class A { static constexpr int X = 1; }; ...
Here's C++ playing a nasty trick on me:
class A
{
static constexpr int X = 1;
};
template<int X>
class B : public A
{
static_assert(X == 1);
};
int main()
{
B<1> Z;
}
Makes sense, I suppose, but it's tricky to have something shadowed by something that might be a long way off. Luckily you get an error message so when all other avenues are exhausted you can start searching - after you conclude that Intellisense is lying about the definition of X.
class A
{
static constexpr int X = 1;
};
template<int X>
class B : public A
{
static_assert(X == 1);
};
int main()
{
B<1> Z;
}
Makes sense, I suppose, but it's tricky to have something shadowed by something that might be a long way off. Luckily you get an error message so when all other avenues are exhausted you can start searching - after you conclude that Intellisense is lying about the definition of X.