当我们在模板声明中看到C类= myarray时,它意味着什么?

tem*_*boy 0 c++

在浏览标准时,我发现模板声明中的一些语法使我感到困惑:

template <typename T> class myarray;

template </*...*/, template <typename T> class C = myarray>
Run Code Online (Sandbox Code Playgroud)

什么class C = myarray意思?它是默认参数吗?谢谢.

Ker*_* SB 5

它是模板模板参数的默认值.如果未指定参数,则默认为myarray.

例:

template <typename> class Foo;
template <typename> class Bar;

template <typename T, template <typename> class C = Foo>
class Zip
{
    typedef C<T> type;  // example use of "C"
    // ...
};

Zip<int, Bar> x;  // OK
Zip<int>      y;  // OK, y has type Zip<int, Foo>
Run Code Online (Sandbox Code Playgroud)