This is the code that has the problem:
template <typename=std::enable_if_t<supports_v<std::equal_to<>, T>> >
bool alreadyValue(const T &value) { return this->value == value; }
// alternate case if T does not support equals operator
bool alreadyValue(const T &value) { return false; }
Here's my support definitions:
template<typename F, typename... T, typename = decltype(std::declval<F>()(std::declval<T>()...))>
std::true_type supports_test(const F&, const T&...);
std::false_type supports_test(...);
template<typename> struct supports;
template<typename F, typename... T> struct supports<F(T...)>
: decltype(supports_test(std::declval<F>(), std::declval<T>()...)){};
template<typename F, typename T>
constexpr bool supports_v = supports<F(T, T)>::value;
template<typename F, typename... T>
constexpr bool all_supports_v = (supports<F(T, T)>::value && ...);
Now, MSVC 19.20 has no problem with this code.
But GCC 9.1 complains that:
In substitution of 'template<bool _Cond, class _Tp> using enable_if_t = typename std::enable_if::type [with bool _Cond = supports_v<std::equal_to<void>, A>; _Tp = void]':
error: no type named 'type' in 'struct std::enable_if<false, void>'
Since SFINAE knows that "no type in struct" should fail silently as its not an error, my question is did I do something wrong?
Here's an example of what I'm working with:
- (GCC 9.1) https://godbolt.org/z/LNfjyp
- (MSVC 19.20) https://godbolt.org/z/wJqXFq
alreadyValue
overload should be a template presumably, etc. – Barryif constexpr
for these kind of cases. Much easier to read. See stackoverflow.com/a/51659883/2466431 – JVApen