Consider the following code:
#include <iostream>
#include <type_traits>
struct Test { Test& operator++(); };
struct NoIncrement { };
template <typename...> using void_t = void;
template <class, class=void_t<>>
struct has_pre_increment_member : std::false_type { };
template <class T>
struct has_pre_increment_member<T, void_t<decltype( ++std::declval<T&>() )>>
: public std::true_type { };
int main() {
std::cout << has_pre_increment_member<Test>::value << " ";
std::cout << has_pre_increment_member<NoIncrement>::value << std::endl;
}
With g++ version 5 and later (and the -std=c++14 flag, of course), this code outputs
1 0
as it should. With g++ version 4.9 (and the -std=c++14 flag), however, it outputs
1 1
Both claim to be using the same language standard, so what's the issue here?