Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/147.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

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++ 模板结构成员的模板参数数目错误(1应为3)_C++_Templates - Fatal编程技术网

C++ 模板结构成员的模板参数数目错误(1应为3)

C++ 模板结构成员的模板参数数目错误(1应为3),c++,templates,C++,Templates,我有一个这样的结构 namespace Binning_ { template <typename data_type, uint32_t number_of_bins, bool uses_integrals> struct Binner { void setup(); /* ... */ namespace Binning{ 模板 结构宾纳{ 无效设置(); /* ... */ 现在我想实现它。当然,我希望我必须以某种方式实现它

我有一个这样的结构

namespace Binning_ {   
    template <typename data_type, uint32_t number_of_bins, bool uses_integrals>
    struct Binner {
        void setup();
    /* ... */
namespace Binning{
模板
结构宾纳{
无效设置();
/* ... */
现在我想实现它。当然,我希望我必须以某种方式实现它

namespace Binning_ {  
    template <typename data_type, uint32_t number_of_bins, bool uses_integrals>
    void Binner<typename data_type, uint32_t number_of_bins, bool uses_integrals>::setup() { 
        /* ... */
    }
namespace Binning{
模板
void Binner::setup(){
/* ... */
}
编译器一直告诉我模板参数的数目错误

/home/udo/dev/libraries/dcf77/dcf77.cpp:305:81: error: wrong number of template arguments (1, should be 3)
     void Binner<typename data_type, uint32_t number_of_bins, bool uses_integrals>::setup() {
                                                                                 ^
/home/udo/dev/libraries/dcf77/dcf77.cpp:259:12: error: provided for 'template<class data_type, long unsigned int number_of_bins, bool uses_integrals> struct Binning_::Binner'
     struct Binner {
            ^
/home/udo/dev/libraries/dcf77/dcf77.cpp:305:81:错误:模板参数的数量错误(1,应该是3)
void Binner::setup(){
^
/home/udo/dev/libraries/dcf77/dcf77.cpp:259:12:错误:为“模板结构Binning\:Binner”提供
结构宾纳{
^

但是我不明白。当然我必须传递3个模板参数。但是为什么编译器只计算1?

您不能重复
Binner
参数列表中的类型:

template <typename data_type, uint32_t number_of_bins, bool uses_integrals>
  void Binner<data_type, number_of_bins, uses_integrals>::setup() { 
        /* ... */
}
模板
void Binner::setup(){
/* ... */
}

应该可以工作。

您不能重复Binner的参数列表中的类型:

template <typename data_type, uint32_t number_of_bins, bool uses_integrals>
  void Binner<data_type, number_of_bins, uses_integrals>::setup() { 
        /* ... */
}
模板
void Binner::setup(){
/* ... */
}
应该有用