std :: promise< T>在Visual Studio 2017中T必须是默认可构造的地方? [英] std::promise<T> where T must be default constructible in Visual Studio 2017?
本文介绍了std :: promise< T>在Visual Studio 2017中T必须是默认可构造的地方?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在Visual Studio 2017中编译以下代码:
I am trying to compile the following code in Visual Studio 2017:
#include <future>
int main()
{
std::promise<std::reference_wrapper<int>> promise;
(void)promise;
}
但是,出现以下错误:
错误C2512:"std :: reference_wrapper":没有合适的默认构造函数
error C2512: 'std::reference_wrapper': no appropriate default constructor available
它可以与GCC和Clang一起很好地编译.
Whereas it compiles fine with GCC and Clang.
这是Visual Studio中的确定错误,还是std :: promise的有效实现?
Is this is a definite bug in Visual Studio or is it a valid implementation of std::promise?
推荐答案
Looks like it is a known issue in MSVC's standard library implementation. A simpler reproduction scenario:
#include <future>
struct NoDefaultCtor
{
NoDefaultCtor() = delete;
};
int main() {
std::promise<NoDefaultCtor> p;
return 0;
}
这篇关于std :: promise< T>在Visual Studio 2017中T必须是默认可构造的地方?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文