Reputation: 426
I recently switched to VS Code from MSVS due to personal reasons, and my compiler is the latest Clang now.
I had some troubles (for example, I can't write typename O = ...
, now I have to write typename O = typename ...
), but all of them are small and easy to fix. Except one.
I don't know the reason, but compiler can't find std::invoke_result_t
and std::invoke_result<>::type
. It's disgusting a lot, especially because IntelliSense finds it easy.
Here's error log:
{"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.
If I use offered std::_Invoke_result_t
instead of normal one, everything compiles and works as it should.
Also, every time I compile my code, that contains std::cout
, compiler write that some locally defined symbols (_CxxThrowException and _std_terminate, to be honest) were imported to functions from .
Is there any way to fix all these troubles? Which of them are bugs and which are features? I heard, VS C++ libraries don't accomplish to ISO standard, does it may be reason of my troubles?
Upvotes: 1
Views: 5993
Reputation: 1387
std::invoke_result
is part of C++17, please ensure that the compiler has the -std=c++17
option.
Also,
#include <type_traits>
If you are using clang or a older version of c++ consider using std::result_of
Upvotes: 4