This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Question on C++-0x constexpr
- From: Gabriel Dos Reis <dosreis at gmail dot com>
- To: Ed Smith-Rowland <3dw4rd at verizon dot net>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Thu, 15 Oct 2009 13:26:28 -0500
- Subject: Re: Question on C++-0x constexpr
- References: <4AD74CC8.3060707@verizon.net>
- Reply-to: gdr at integrable-solutions dot net
On Thu, Oct 15, 2009 at 11:24 AM, Ed Smith-Rowland <3dw4rd@verizon.net> wrote:
> I was toying around with constexpr in the standard library and tripped on
> this:
> ------------------------------------------------------------------------------------------------------------
> // /bin/bin/g++ -std=c++0x -c template_constexpr.cpp
>
> template<typename T>
> class A
> {
> ?static constexpr int foo() { return 666; }
> };
>
> template<typename E>
> class B
> {
> ?static constexpr int foo() { return e.foo(); } ?// ?Should the compiler be
> able to noodle this out?
invalid.
> ?static constexpr int bar() { return E::foo(); } ?// ?Works fine.
> private:
> ?E e;
> };
>
> template_constexpr.cpp: In static member function 'static int B<E>::foo()':
> template_constexpr.cpp:16:5: error: invalid use of member 'B<E>::e' in
> static member function
> template_constexpr.cpp:13:39: error: from this location
> ------------------------------------------------------------------------------------------------------------
>
> Question, if you can use a member access operator to access a static member,
> shouldn't constexpr work through that method too?
only after all other semantics restrictions are met,
BTW: current 'constexpr' is preliminary. There is more to come -- patch
under review.
>
> Thanks,
>
> Ed Smith-Rowland
>
>