I am trying to use std::experimental::detect_or_t from <experimental/type_traits> .
Which compiler, option, version or library do I need to compile the following example from 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 difference_type should be int!"); static_assert(std::is_same<difference_type<Purr>, std::ptrdiff_t>::value, "Purr difference_type should be ptrdiff_t!"); }
I tried using clang++ -std=c++14 and g++ -std=c++14 . Also with -std=c++1y and -std=c++17 . I always get the following:
main.cpp:8:44: error: 'detected_or_t' in namespace 'std::experimental' does not name a template type
source share