error: no template named 'is_same_v' in namespace 'std'; did you mean 'is_same'?

error: no template named 'is_same_v' in namespace 'std'; did you mean 'is_same'?

这是已解决的 的跟进。但是,我收到这个错误:

error: no template named 'is_same_v' in namespace 'std'; did you mean 'is_same'?
    !std::is_same_v<typename std::iterator_traits<T>::value_type, void>, O
     ~~~~~^~~~~~~~~
          is_same
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/type_traits:831:61: note: 'is_same' declared here
template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same           : public false_type {};
                                                            ^

基于

... it was added in C++14, as were most of the other type trait *_t versions ... C++17 added *_v versions as inline constexpr variables ...

所以,is_same_v 是 C++17 添加的。但是我已经通过以下方式将 C++14 和 C++17 添加到 QMake:

CONFIG += c++14
CONFIG += c++17
QMAKE_CXXFLAGS += -std=c++14
QMAKE_CXXFLAGS += -std=c++17

XCode (Clang) 是否可能缺少某些 C++17 功能?我的 Xcode 版本是 9.4.1,我的 Clang++ 版本是:

$ /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

代码

代码中有 C++14 *_t 类型特征版本和 C++17 *_v 版本,来自有许多贡献者的存储库:

template<class T, class O = T>
using IteratorOnly = std::enable_if_t<
    !std::is_same_v<typename std::iterator_traits<T>::value_type, void>, O
>;

观察

当我在 QMake 项目文件中使用 CONFIG += c++14 时,我只收到这个错误:

error: no template named 'is_same_v' in namespace 'std'; did you mean 'is_same'?

当我在 QMake 项目文件中使用 CONFIG += c++17 时,我收到以下两个错误:

error: no template named 'enable_if_t' in namespace 'std'; did you mean 'enable_if'?

error: no template named 'is_same_v' in namespace 'std'; did you mean 'is_same'?

为什么?

工具链支持 C++17。因此,最终,将 std::is_same_v 替换为 std::is_same ...