Переопределение типа возвращаемого значения в специализации шаблона функции ⇐ C++
Переопределение типа возвращаемого значения в специализации шаблона функции
I would like to specialize a function template such that the return type changes depending on the type of the template argument.
class ReturnTypeSpecialization { public: template T Item(); }; // Normally just return the template type template T ReturnTypeSpecialization::Item() { ... } // When a float is specified, return an int // This doesn't work: template int ReturnTypeSpecialization::Item() { ... } Is this possible? I can't use C++11.
Источник: https://stackoverflow.com/questions/159 ... ialization
I would like to specialize a function template such that the return type changes depending on the type of the template argument.
class ReturnTypeSpecialization { public: template T Item(); }; // Normally just return the template type template T ReturnTypeSpecialization::Item() { ... } // When a float is specified, return an int // This doesn't work: template int ReturnTypeSpecialization::Item() { ... } Is this possible? I can't use C++11.
Источник: https://stackoverflow.com/questions/159 ... ialization
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Как использовать частичные специализации в качестве параметров шаблона шаблона?
Anonymous » » в форуме C++ - 0 Ответы
- 20 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Специализация шаблона функции C++ на основе шаблонного типа возвращаемого значения.
Anonymous » » в форуме C++ - 0 Ответы
- 16 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Разрешается ли компилятору игнорировать встроенные значения в случае специализации шаблона?
Anonymous » » в форуме C++ - 0 Ответы
- 11 Просмотры
-
Последнее сообщение Anonymous
-