Oracle Solaris Studio 12.2:C++ 用户指南

6.6.1 模板专门化声明

使用模板参数的组合之前,您必须声明专门化。以下示例声明了twicesort 的专用实现。


template <> unsigned twice<unsigned>( unsigned original );

template <> sort<char*>(Array<char*> store);

如果编译器可以明确决定模板参数,则您可以省略模板参数。例如:


template <> unsigned twice(unsigned original);

template <> sort(Array<char*> store);