Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;一个函数上有两个模板关键字_C++_Templates - Fatal编程技术网

C++ C++;一个函数上有两个模板关键字

C++ C++;一个函数上有两个模板关键字,c++,templates,C++,Templates,观察random.tccSTL源文件发现以下运算符定义: template<typename _IntType> template<typename _UniformRandomNumberGenerator> typename geometric_distribution<_IntType>::result_type geometric_distribution<_IntType>:: operat

观察
random.tcc
STL源文件发现以下运算符定义:

  template<typename _IntType>
    template<typename _UniformRandomNumberGenerator>
      typename geometric_distribution<_IntType>::result_type
      geometric_distribution<_IntType>::
      operator()(_UniformRandomNumberGenerator& __urng,
         const param_type& __param)
      {
    // About the epsilon thing see this thread:
    // http://gcc.gnu.org/ml/gcc-patches/2006-10/msg00971.html
    const double __naf =
      (1 - std::numeric_limits<double>::epsilon()) / 2;
    // The largest _RealType convertible to _IntType.
    const double __thr =
      std::numeric_limits<_IntType>::max() + __naf;
    __detail::_Adaptor<_UniformRandomNumberGenerator, double>
      __aurng(__urng);

    double __cand;
    do
      __cand = std::floor(std::log(1.0 - __aurng()) / __param._M_log_1_p);
    while (__cand >= __thr);

    return result_type(__cand + __naf);
      }
模板
模板
typename几何分布::结果类型
几何分布::
运算符(),
常量参数(类型和参数)
{
//关于epsilon的事情,请看以下线索:
// http://gcc.gnu.org/ml/gcc-patches/2006-10/msg00971.html
常数双=
(1-std::numeric_limits::epsilon())/2;
//可转换为_IntType的最大_RealType。
双常数=
std::numeric_limits::max()+__naf;
__详细信息::\u适配器
__aurng(uuu urng);
双倍烛光;
做
__cand=std::floor(std::log(1.0-_aurng())/__参数_M_log_1_p);
而(\uu cand>=\uu thr);
返回结果类型(uuu cand+uuu naf);
}

谷歌和各种C++引用没有帮助我理解当两个代码< >模板>代码>声明时意味着什么。请帮助那些知道的人。

这是模板中的模板

从声明中更容易看出,它可能看起来像这样

template<typename _IntType>
class geometric_distribution
{
    ...
    template<typename _UniformRandomNumberGenerator>
    result_type operator()(_UniformRandomNumberGenerator& __urng, const param_type& __param);
    ...
};
模板
类几何分布
{
...
模板
结果类型运算符();
...
};

这是模板类的模板方法定义。是的,
random.h
中有一个定义:
模板类几何分布{…
。谢谢!