I recently upgraded GCC to 8.2, and most of my SFINAE expressions have stopped working.
The following is somewhat simplified, but demonstrates the problem:
Partial answer: use typename = typename enable_if<...>, T=0 with different Ts:
#include
#include
class Class {
public:
template <
typename U,
typename = typename std::enable_if_t<
std::is_const::type>::value
>, int = 0
>
void test() {
std::cout << "Constant" << std::endl;
}
template <
typename U,
typename = typename std::enable_if_t<
!std::is_const::type>::value
>, char = 0
>
void test() {
std::cout << "Mutable" << std::endl;
}
};
int main() {
Class c;
c.test();
c.test();
return 0;
}
(demo)
Still trying to figure out what the heck does std::enable_if<...>::type... mean knowing the default type is void.