I am writing a class in which I want to create a member function template specification like this
namespace aha { class Foo { public: template < typename T > T To() const {
gcc gives an error:
Explicit instance creation of 'To <bool>' after instance creation
I would like to do this with a specialized member function only so that my library users get the same function when converting Foo to different data types, such as
Foo obj; bool b( obj.To < std::string > () ); int i( obj.To < int > () ); float f( obj.To < float > () );
etc.
Please let me know what I am doing wrong in the code.
source share