Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/141.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++ 是否可以重载一个函数以接受具有非类型模板参数的所有实例 模板结构A{ (一); }; 模板 无效剂量测定(A&A){ std::cout模板 无效剂量测定(A和值) {...} template<typename T,int I=5> str_C++_Templates_Specialization_Non Type - Fatal编程技术网

C++ 是否可以重载一个函数以接受具有非类型模板参数的所有实例 模板结构A{ (一); }; 模板 无效剂量测定(A&A){ std::cout模板 无效剂量测定(A和值) {...} template<typename T,int I=5> str

C++ 是否可以重载一个函数以接受具有非类型模板参数的所有实例 模板结构A{ (一); }; 模板 无效剂量测定(A&A){ std::cout模板 无效剂量测定(A和值) {...} template<typename T,int I=5> str,c++,templates,specialization,non-type,C++,Templates,Specialization,Non Type,是否可以重载一个函数以接受具有非类型模板参数的所有实例 模板结构A{ (一); }; 模板 无效剂量测定(A&A){ std::cout模板 无效剂量测定(A和值) {...} template<typename T,int I=5> struct A{ T _store[I]; }; template<typename T,int I> void doSomething(A<T,I>& a){ std::cout <<

是否可以重载一个函数以接受具有非类型模板参数的所有实例
模板结构A{
(一);
};
模板
无效剂量测定(A&A){
std::cout
模板
无效剂量测定(A和值)
{...}
template<typename T,int I=5> struct A{

    T _store[I];

};

template<typename T,int I>
void doSomething(A<T,I>& a){

  std::cout << "basic template for all other types" << std::endl;

}

template<>
void doSomething(A<int>& a){

 std::cout << "specialized integer template" << std::endl;

}

int main(int argc, char** argv){


    A<char> a;
    A<int> i;
    A<int,10> i10;

    doSomething(a);
    doSomething(i);
    doSomething(i10); //this does not call any specialized version yet

    return 0;

}
template<int I>
void doSomething(A<int, I> & value)
{...}