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?
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?
Thanks,
Ed Smith-Rowland