由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 如何使用这个template?
相关主题
请问const myClass &src 和myClass const &src有什么区别?急问:VS2008里如何调用DLL
请教一下这个template function在gcc下要怎么修改typedef const char *month Table[3]
问个关于随机数生成器的问题C++ STL map find does not work ???
[合集] 关于template和inheritance的问题请教有段c++代码看不懂
一个C++ template的问题一个C语言的面试题,有点乱,麻烦看一下
请教随机数生成问题请教一个C++ typedef的问题
Why the number is not exact in C++为啥允许这样的const设计
问个小问题sgi stl 源代码一问
相关话题的讨论汇总
话题: realtype话题: template话题: type话题: const
进入Programming版参与讨论
1 (共1页)
f****n
发帖数: 20
1
boost里有这么一个生成正态分布随机数的template.
template
class normal_distribution
{
public:
typedef RealType input_type;
typedef RealType result_type;
explicit normal_distribution(const result_type& mean = 0,
const result_type& sigma = 1);
RealType mean() const;
RealType sigma() const;
void reset();
template
result_type operator()(UniformRandomNumberGenerator& urng);
};
如果想把UniformRandomNumberGenerator指定为lagged_fibon
f****n
发帖数: 20
2
主要问题是这个class template有个member是function template,而且template
parameters在两个位置出现,哪位同学给解释一下?多谢
c********e
发帖数: 383
3
there is a thing for function template called template parameter deduction

【在 f****n 的大作中提到】
: 主要问题是这个class template有个member是function template,而且template
: parameters在两个位置出现,哪位同学给解释一下?多谢

t****t
发帖数: 6806
4
从prototype看这个class设计思想是这样.
class的参数明显是数据类型,多半不是float就是double
那个operator()的参数是uniform generator class,因为高斯随机数通常是由均匀分布
的随机数变换而来,而uniform的质量有不一样,所以为灵活起见要求你提供一个.
用的时候这样写
normal_distribution n_prng(mean, sigma);
lagged_fibonacci607 u_prng( ... );
double x=n_prng(u_prng);

【在 f****n 的大作中提到】
: boost里有这么一个生成正态分布随机数的template.
: template
: class normal_distribution
: {
: public:
: typedef RealType input_type;
: typedef RealType result_type;
: explicit normal_distribution(const result_type& mean = 0,
: const result_type& sigma = 1);
: RealType mean() const;

f****n
发帖数: 20
5
你的解释很清楚,多谢帮助
1 (共1页)
进入Programming版参与讨论
相关主题
sgi stl 源代码一问一个C++ template的问题
C++ cast 小结请教随机数生成问题
c++ template question:Why the number is not exact in C++
boost::function 的 syntax 问题问个小问题
请问const myClass &src 和myClass const &src有什么区别?急问:VS2008里如何调用DLL
请教一下这个template function在gcc下要怎么修改typedef const char *month Table[3]
问个关于随机数生成器的问题C++ STL map find does not work ???
[合集] 关于template和inheritance的问题请教有段c++代码看不懂
相关话题的讨论汇总
话题: realtype话题: template话题: type话题: const