http://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution/params http://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution/min http://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution/max
看起来成员函数a()
等同于成员函数min()
,而成员函数b()
等同于max()
。
#include <iostream>
#include <random>
int main() {
std::uniform_int_distribution<int> dist(5, 10);
std::cout << "a " << dist.a() << '\n';
std::cout << "b " << dist.b() << '\n';
std::cout << "min " << dist.min() << '\n';
std::cout << "max " << dist.max() << '\n';
}
打印
a 5
b 10
min 5
max 10
使用gcc标准库编译时,这些函数是否真的相同?如果是,为什么要定义a()和b()函数?