I'm trying to compile this (C++14) code using VC++ 2017.
#include <type_traits>
#include <limits>
struct Templ
{
template <typename T>
static constexpr int value = ( std::numeric_limits<T>::min() == 0 );
};
using type = std::conditional_t<Templ::value<unsigned>, bool, double>;
int main()
{
return 0;
}
I get the following error message:
unresolved external symbol "public: static int const Templ::value" (??$value@I@Templ@@2HB) referenced in function "void __cdecl Templ::`dynamic initializer for 'public: static int const Templ::value''(void)" (??__E??$value@I@Templ@@2HB@Templ@@YAXXZ)|
How can I correctly use conditional_t with a templated static constexpr member as the condition?
Edit. Based on Some programmer dude's answer I came up with this:
struct Templ
{
template<typename T>
struct inner
{
enum
{
value = ( std::numeric_limits<T>::min() == 0 )
};
};
};
using type = std::conditional_t<Templ::inner<unsigned>::value, bool, double>;
Templ::value<double>and you don't have it in your code. Is the code you show truly a minimal reproducible example that generates the error you show? - Some programmer dude