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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/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++中是否可以选择可选的模板参数,例如 template < class T, class U, class V> class Test { };_C++_Templates_Optional Parameters - Fatal编程技术网

可选模板参数 在C++中是否可以选择可选的模板参数,例如 template < class T, class U, class V> class Test { };

可选模板参数 在C++中是否可以选择可选的模板参数,例如 template < class T, class U, class V> class Test { };,c++,templates,optional-parameters,C++,Templates,Optional Parameters,如果是,如何执行此操作。当然,您可以使用默认模板参数: template <typename T, typename U, typename V = U> template <typename T, typename U = int, typename V = std::vector<U> > Typicall您只需将其用作std::unordered\u map,无需进一步考虑。您可以使用默认的模板参数,这些参数对于您的目的来说已经足够了: templa

如果是,如何执行此操作。

当然,您可以使用默认模板参数:

template <typename T, typename U, typename V = U>

template <typename T, typename U = int, typename V = std::vector<U> >
Typicall您只需将其用作
std::unordered\u map
,无需进一步考虑。

您可以使用默认的模板参数,这些参数对于您的目的来说已经足够了:

template<class T, class U = T, class V = U>
class Test
{ };
模板
课堂测试
{ };
现在进行以下工作:

Test<int> a;           // Test<int, int, int>
Test<double, float> b; // Test<double, float, float>
测试a;//试验
测试b;//试验
template<class T, class U = T, class V = U>
class Test
{ };
Test<int> a;           // Test<int, int, int>
Test<double, float> b; // Test<double, float, float>