Переопределение типа возвращаемого значения в специализации шаблона функции ⇐ 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
Мобильная версия