Is there a way I can assert that two constant expressions are equal at compile time?
e.g. I want this to cause a compile-time error
enum { foo=263,
I would go for one of the available static_asserts.
But just because I have never tried before I wrote this:
enum { foo=263, bar=264 };
template
struct CompileAssert
{
bool assert() {}
};
template<>
struct CompileAssert {}; // fail on false.
int main()
{
CompileAssert().assert(); // Now I have seen Chad above I like his static
CompileAssert().assert(); // method better than using a normal method.
} // But I tried zero length arrays first did
// not seem to work