Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;离散分布中的编译错误_C++_Visual Studio_Stl - Fatal编程技术网

C++ C++;离散分布中的编译错误

C++ C++;离散分布中的编译错误,c++,visual-studio,stl,C++,Visual Studio,Stl,我在下面的几行中遇到了一个编译错误,我不能完全理解。 根据语法是正确的 vector<int> temp_weights = //some data will be here discrete_distribution<int> weights ({ temp_weights.begin(), temp_weights.end() }); //error C2440 vector temp_weights=//此处将显示一些数据 离散分布权重({temp_-weigh

我在下面的几行中遇到了一个编译错误,我不能完全理解。 根据语法是正确的

vector<int> temp_weights = //some data will be here

discrete_distribution<int> weights ({ temp_weights.begin(), temp_weights.end() }); //error C2440
vector temp_weights=//此处将显示一些数据
离散分布权重({temp_-weights.begin(),temp_-weights.end()})//错误C2440
完全错误是:

Error   5   error C2440: 'initializing' : cannot convert from 'initializer-list' to 'std::discrete_distribution<int>'   
错误5错误C2440:“正在初始化”:无法从“初始值设定项列表”转换为“std::离散分布”

离散分布权重{temp\u weights.begin(),temp\u weights.end()}

这不起作用的原因是因为它是初始化列表的语法, 编译器认为您希望在
权重[0]
处存储
临时权重。begin()
,并且
temp\u weights.end()
at
weights[1]

应该有一个接受两个
vector::iterator
的构造函数(以便跨多个元素复制vectors),因此这应该适合您


离散分布权重(temp_-weights.begin()、temp_-weights.end())
离散分布权重{temp\u weights.begin(),temp\u weights.end()}

这不起作用的原因是因为它是初始化列表的语法, 编译器认为您希望在
权重[0]
处存储
临时权重。begin()
,并且
temp\u weights.end()
at
weights[1]

应该有一个接受两个
vector::iterator
的构造函数(以便跨多个元素复制vectors),因此这应该适合您


离散分布权重(temp_-weights.begin()、temp_-weights.end()) < /P>请注意您的完整编译器版本。@ TAMBRE:它是VisualStudioC++ 2013更新版。请注意您的完整编译器版本。@ TAMBRE:它是VisualStudioC++ 2013更新5thx,但在我的版本中似乎没有这样的构造函数,因为我得到了错误:
error 5 error C2661:'std::discrete_distribution::discrete_distribution':没有重载函数接受2个参数
,不幸的是,这个错误可能是由于您的vs2013 thx版本中的错误造成的,但在我的版本中似乎没有这样的构造函数,因为我得到了错误:
error 5 error C2661:'std::discrete_distribution::discrete_distribution':没有重载函数接受2个参数
,不幸的是,该错误可能是由于vs2013版本中的错误造成的