我需要什么编译器 option/library 才能使用 detect_or_t 类型特征?

What compiler option/library do I need to use detect_or_t type trait?

我正在尝试使用 <experimental/type_traits> 中的 std::experimental::detect_or_t

http://en.cppreference.com/w/cpp/experimental/is_detected 编译以下示例需要什么编译器、选项、版本或库?

#include <experimental/type_traits>
#include <cstddef>

template<class T>
using diff_t = typename T::difference_type;

template <class Ptr>
using difference_type = std::experimental::detected_or_t<std::ptrdiff_t, diff_t, Ptr>;

struct Meow { using difference_type = int; };
struct Purr {};

int main()
{
    static_assert(std::is_same<difference_type<Meow>, int>::value, "Meow's difference_type should be int!");
    static_assert(std::is_same<difference_type<Purr>, std::ptrdiff_t>::value, "Purr's difference_type should be ptrdiff_t!");
}

我尝试使用 clang++ -std=c++14g++ -std=c++14。还有 -std=c++1y-std=c++17。我总是这样:

main.cpp:8:44: error: 'detected_or_t' in namespace 'std::experimental' does not name a template type

这些特性首先添加到 GCC 6.1.0 中的 libstdc++,如 GCC 6 release notes:

中所述
  • Experimental support for most features of the second version of the Library Fundamentals TS.

以及手册中的实施状态表,位于 https://gcc.gnu.org/onlinedocs/gcc-6.1.0/libstdc++/manual/manual/status.html#table.cxx1z_ts_status

我对libc++不太确定,但Clang 3.9.1版本不支持,但当前主干支持,所以我认为它们首先出现在Clang 4.0.0