Следующий код завершается ошибкой, если не опущено noexcept.Есть ли способ сохранить noexcept
и исправить эту ошибку?
Ошибка (и):
> functional(1479) : error C2027 : use of undefined type 'std::_Get_function_impl<_Fty>'
with
[
_Fty = void(std::string &) noexcept
]
> functional(1479) : note : see declaration of 'std::_Get_function_impl<_Fty>'
with
[
_Fty = void(std::string &) noexcept
]
> main.cpp(5) : note : see reference to class template instantiation 'std::function<void (std::string &) noexcept>' being compiled
> functional(1480) : error C2504 : 'type' : base class undefined
[more errors]
> error C2664: 'void bar(functor_t)': cannot convert argument 1 from 'void (__cdecl *)(std::string &) noexcept' to 'functor_t'
Код:
#include <functional>
#include <string>
using namespace std;
typedef function<void(string&) noexcept> functor_t;
void bar(functor_t f) {
string args{ "a" };
f(args);
}
void foo(string& args) noexcept { }
int main() {
bar(foo);
}
Это похоже напроблема с VC ++ и его текущей версией библиотеки std.Помимо удаления noexcept
есть ли обходной путь, который позволит этому коду работать для x64 в Visual C ++?
Я использую Visual Studio версии 15.8.7, Windows SDK версии 10.0.17134.0 иvc \ tools \ msvc \ 14.15.26726 (все последние версии).
Заранее спасибо.
Редактировать # 1:
строка 1631 функционала:
#define _FUNCTION_POINTER_DEDUCTION_GUIDE(CALL_OPT, X1, X2, X3) \
template<class _Ret, \
class... _Types> \
function(_Ret (CALL_OPT *)(_Types...)) \
-> function<_Ret (_Types...)>; // intentionally discards CALL_OPT
Похоже, что приведенный выше код не соответствует подписи в x64 (?).Может кто-нибудь подтвердить это (я новичок в C ++ 17).