new requirement of "constexpr" for static const float data members is too restrictive

Richard Guenther richard.guenther@gmail.com
Tue Nov 30 13:53:00 GMT 2010


On Tue, Nov 30, 2010 at 9:17 AM, Miles Bader <miles@gnu.org> wrote:
> On Tue, Nov 30, 2010 at 5:13 PM, Gabriel Dos Reis
> <gdr@integrable-solutions.net> wrote:
>> If you are doing that, why don't you write a simpler code by
>> just defining (e.g. initializing) the data member outside the class?
>
> 'cause I want the compiler to be able to use (inline) the underlying values.

I think it'll do that with initializing the member outside of the class as well.

struct X { static float const v; };
const float X::v = 1;
int main()
{
  return (int)X::v;
}

at least works for me (even when not optimizing - huh).

Richard.

> -Miles
>
> --
> Cat is power.  Cat is peace.
>



More information about the Gcc mailing list