Переопределение типа возвращаемого значения в специализации шаблона функцииC++

Программы на 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

Вернуться в «C++»