错误:名称空间"std"中没有名为"enable_if_t"的模板;您的意思是"enable_if"吗? [英] error: no template named 'enable_if_t' in namespace 'std'; did you mean 'enable_if'?

查看:295
本文介绍了错误:名称空间"std"中没有名为"enable_if_t"的模板;您的意思是"enable_if"吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用macOS 10.13.6上的Qt 5.11.3进行编译.Qt使用的clang版本是:

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

但是我收到此错误:

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

推荐答案

模板别名 enable_if_t 在C ++ 11中不可用.它是在C ++ 14中添加的,就像其他大多数类型特征 * _ t 版本一样(C ++ 17在 * _ v 版本中添加了 inline constexpr 变量).

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 as inline constexpr variables).

这篇关于错误:名称空间"std"中没有名为"enable_if_t"的模板;您的意思是"enable_if"吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆