2
当我使用boost/random/uniform_int_distribution.hpp
,做我收到此错误:预期的类型说明符
boost::random::uniform_int_distribution<> dist(0, 5);
我得到的错误是:
$ 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 '>'
为什么我得到这个错误?
注意:当我使用std::uniform_int_distribution<>
时,我不会收到此错误。
这是引起问题的代码:
#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()
{
}
@JonathonReinhart它是,类模板有一个默认的类型参数“int”。 OP:请发布重现错误的[SSCCE](http://sscce.org)。孤立的单行代码是无用的,无论是gcc还是clang [编译没有错误](http://coliru.stacked-crooked.com/a/1233cfc5e28a9e55)。 – Praetorian
@Praetorian更新。 – user2030677
@Praetorian在Coliru上它说“没有类型名为'default_random_engine'在命名空间增强中”。那么'default_random_engine'的正确头文件是什么? – user2030677