What is Nostr?
Dan Piponi /
npub1xs3…grae
2024-09-19 19:58:43

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.
Author Public Key
npub1xs30e0pj7velktf5sxewnqf93tu2pdt3s6wtl6fug2tzgy8zxthsgfgrae