【发布时间】:2018-01-10 15:00:05
【问题描述】:
我最近因为个人原因从MSVS切换到VS Code,我的编译器现在是最新的Clang。
我遇到了一些麻烦(例如,我不能写typename O = ...,现在我必须写typename O = typename ...),但它们都很小,很容易修复。除了一个。
我不知道原因,但是编译器找不到std::invoke_result_t 和std::invoke_result<>::type。这很恶心,尤其是因为 IntelliSense 发现它很容易。
这是错误日志:
{"Workspace" directory}/Untitled-1.cpp:5:54: error: no template named 'invoke_result_t' in namespace 'std'; did you mean '_Invoke_result_t'?
template<typename I, typename FTy, typename O = std::invoke_result_t<std::function<FTy>, I>>
~~~~~^~~~~~~~~~~~~~~
_Invoke_result_t
{MSVS Installation directory}\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include\type_traits:1832:2: note: '_Invoke_result_t' declared here
using _Invoke_result_t = typename _Invoke_traits<void, _Callable, _Args...>::type;
^
1 error generated.
如果我使用提供的std::_Invoke_result_t 而不是普通的,一切都会编译并正常运行。
此外,每次我编译包含 std::cout 的代码时,编译器都会写入一些本地定义的符号(老实说,_CxxThrowException 和 _std_terminate)被导入到函数中。
有什么办法可以解决所有这些问题吗?其中哪些是错误,哪些是功能?听说VS C++库不符合ISO标准,是不是我的问题?
【问题讨论】:
-
显示代码,获取帮助。
-
根据this page,它在VS 2017.3中可用。
-
std::invoke_result 是 AFAIK not yet implemented in clang。问题2087.
-
@GuillaumeRacicot 这是
O不是0;) -
显示你的命令行。 Clang 的默认仍然是 C++98,所以你必须做一些特殊的事情才能得到 C++03、C++11、C++14、C++17 或 C++20(和朋友)。据我了解,Clang 6 默认使用 C++14。另见Issue 35853, Clang 4.0 still uses C++98 by default。
标签: c++ visual-studio-code clang std c++17