Reputation: 3526
I am getting this error when I use boost/random/uniform_int_distribution.hpp
and do:
boost::random::uniform_int_distribution<> dist(0, 5);
The error I get is:
$ g++ game.cpp -std=c++11 -Wall -Ipath/to/boost -o game && ./game
game.cpp:11:20: error: expected type-specifier
game.cpp:11:20: error: expected '>'
Why am I getting this error?
Note: I don't get this error when I use std::uniform_int_distribution<>
.
This is the code causing the problem:
#include <boost/random/uniform_int_distribution.hpp>
template<
class Engine = boost::default_random_engine
>
class game
{
boost::random::uniform_int_distribution<int> dist{0, 5};
};
int main()
{
}
Upvotes: 2
Views: 1060
Reputation: 109109
Boost.Random doesn't define a default_random_engine
type. Use the Mersenne twister engine directly instead (or one of the other generators it defines)
#include <boost/random/uniform_int_distribution.hpp>
#include <boost/random/mersenne_twister.hpp>
template<
class Engine = boost::mt19937
>
class game
{
boost::random::uniform_int_distribution<> dist{0, 5};
};
Also, since the question is tagged C++11, I'll mention that the standard library does define both std::default_random_engine
and std::uniform_int_distribution
in the <random>
header.
Upvotes: 5