This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
g++-3.4: static const bool in template struct rejected - why?
- From: Markus Werle <numerical dot simulation at web dot de>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 26 Feb 2003 11:35:54 +0100
- Subject: g++-3.4: static const bool in template struct rejected - why?
Hi!
Maybe I am again missing some (new) detail of the C++ standard, so
forgive me if this ain't a bug and enlighten me.
-------------------------------------------
template <class T1, class T2>
struct Is { static const bool SameType = false; };
template <class T>
struct Is<T, T> { static const bool SameType = true; };
#define SAME_TYPE(T1, T2) Is<T1, T2>::SameType
template <class T>
struct Test
{
static const bool test1 = SAME_TYPE(double, T);
static const bool test2 = false;
static const bool result = test1 || test2;
};
int main() {
Test<double> T1;
}
-------------------------------------------
# g++ GCC-3.4-CannotAppearInConstantExpr.C
GCC-3.4-CannotAppearInConstantExpr.C:16: error: `
Test<T>::test1' cannot appear in a constant-expression