I have the following c++14 code:
template<typename T>
struct Test{
static constexpr auto something{T::foo()};
};
This is perfectly fine, provided that T::foo()
is a constexpr
as well.
Now I have that something
is ODR used, so I need to provide a namespace declaration. What syntax should I use?
template<typename T>
constexpr auto Test<T>::something;
Doesn't work. Thanks!
What about passing through a using
defined typename ?
template <typename T>
struct Test
{
using someType = decltype(T::foo());
static constexpr someType something{T::foo()};
};
template<typename T>
constexpr typename Test<T>::someType Test<T>::something;