我有一个像这样的结构
namespace Binning_ {
template <typename data_type, uint32_t number_of_bins, bool uses_integrals>
struct Binner {
void setup();
/* ... */
现在我想实现它。当然我希望我必须以某种方式实现它
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() {
/* ... */
}
编译器一直告诉我模板参数的数量错误。
/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 {
^
但是我没理解。当然,我必须传递3个模板参数。但为什么编译器只计算1?
答案 0 :(得分:6)
您不得在Binner
的参数列表中重复这些类型:
template <typename data_type, uint32_t number_of_bins, bool uses_integrals>
void Binner<data_type, number_of_bins, uses_integrals>::setup() {
/* ... */
}
应该有用。