[cfe-dev] constexpr static methods
Miles Bader
miles at gnu.org
Thu Jan 12 17:46:38 PST 2012
Hi, with the following prog:
class X
{
X ();
constexpr static int foo () { return 3; }
};
compiling with options "-c -std=c++11", I get this error from clang++:
clang++ -c -std=c++11 /tmp/x.cc
/tmp/x.cc:4:24: error: non-literal type 'X' cannot have constexpr members
constexpr static int foo () { return 3; }
^
/tmp/x.cc:1:7: note: 'X' is not literal because it is not an aggregate and has
no constexpr constructors other than copy or move constructors
class X
^
1 error generated.
Is this correct? Such an error would make sense for a non-static
method, but it seems pretty weird for a static method...
gcc trunk (aka 4.7) accepts the above, but gives a similar error if I
remove "static".
[This originally arose trying to compile with libstdc++ from the gcc
trunk (specifically: "#include <random>").]
Thanks,
-Miles
--
`...the Soviet Union was sliding in to an economic collapse so comprehensive
that in the end its factories produced not goods but bads: finished products
less valuable than the raw materials they were made from.' [The Economist]
More information about the cfe-dev
mailing list