5

I'm compiling with Qt 5.11.3 on macOS 10.13.6. The clang version used by Qt is:

$ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -v
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

But I'm receiving this error:

error: no template named 'enable_if_t' in namespace 'std'; did you mean 'enable_if'?
using FloatingOnly = std::enable_if_t<std::is_floating_point<T>::value, O>;
                     ~~~~~^~~~~~~~~~~
                          enable_if
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/type_traits:423:63: note: 'enable_if' declared here
template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {};
                                                              ^

Tried

So far, I have done these, with no effect:

// On source *.cpp file

#include <type_traits>
# On project *.pro file

CONFIG += c++17
QMAKE_CXXFLAGS += -std=c++17 # for Clang
QMAKE_CXXFLAGS += -stdlib=libc++ # xcode_settings
QMAKE_CXXFLAGS += -std=c++11

Error resolved

I just used these and the error got resolved:

CONFIG += c++14
CONFIG += c++17
Megidd
  • 7,089
  • 6
  • 65
  • 142

1 Answers1

7

The template alias enable_if_t is not available in C++11; it was added in C++14, as were most of the other type trait *_t versions (C++17 added *_v versions for boolean traits as inline constexpr variables).

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982