I'm currently porting my library, but my dark template magic won't get compiled with GCC 5.3
This fragment works as expected when compiled with MSVC2015 Update 2
template<typename vreal =
std::enable_if<std::is_vreal<vreal>::value,
floatType>::type>
inline vreal foo(vreal bar)
{
return bar;
}
template<typename vreal =
std::enable_if<std::is_vreal<vreal>::value,
floatType>::type>
struct bar { vreal i; };
GCC complains about "vreal was not defined in current scope (WTF?)"
What I've tried so far:
Rewrite the upper template fragment to
template<typename vreal,
typename enable = typename std::enable_if<std::is_vreal<vreal>::value != 0>::type>
But this doesn't work either. It breaks much much later in the code and I assume that it's due the introduction of the additional template param.
Also, I don't understand why I had to introduce the comparison with 0. Without it gcc complained about missing 'type' on enabled_if.
So, the main question is: how to get the same SFINAE logic (compile ONLY if the argument is vreal) WITHOUT additional arguments.
I could rewrite that to return type SFINAE - but that would be a lot of work which I'd like to avoid (differentiating between functions, classes, structs, typedefs / usings...) even though it's wrapped in a macro.
template<typename vreal>
typename std::enable_if<is_vreal<vreal>, vreal>::type inline vreal .....