Constant expression with custom object
Posted
by nils
on Stack Overflow
See other posts from Stack Overflow
or by nils
Published on 2010-03-26T08:21:08Z
Indexed on
2010/03/26
8:23 UTC
Read the original article
Hit count: 444
I'm trying to use an instant of a custom class as a template parameter.
class X {
public:
X() {};
};
template <class Foo, Foo foo>
struct Bar {
};
const X x;
Bar<X, x> foo;
The compiler states that x
cannot appear in a constant expression. Why that? There is everything given to construct that object at compile time.
© Stack Overflow or respective owner