c++ - Creating a discrete distribution in Visual Studio -


i want create own discrete distribution in visual studio 121 integers. here code trying:

std::vector< int> weights(121); (int = 0; < 121; i++) {     weights[i] = (teamdata[i]).s(); // numbers program data  } std::discrete_distribution<> dist(weights.begin(), weights.end()); 

i intellisence error:

1   intellisense: no instance of constructor "std::discrete_distribution<_ty>::discrete_distribution [with _ty=int]" matches argument list         argument types are: (std::_vector_iterator<std::_vector_val<std::_simple_types<int>>>, std::_vector_iterator<std::_vector_val<std::_simple_types<int>>>)     

and when compile get:

error 1 error c2661: 'std::discrete_distribution::discrete_distribution' : no overloaded function takes 2 arguments
know fix this?

http://en.cppreference.com/w/cpp/numeric/random/discrete_distribution/discrete_distribution

you initializing iterators need use constructor

template< class inputit > discrete_distribution( inputit first, inputit last ); 

so i'm guessing should std::discrete_distribution<int&> dist(weights.begin(), weights.end());

but haven't used discrete_distribution before.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -