overloading std::string operators requires template<> syntax ! Howto ?

Hi all,

I need to overload a cast to u_int32_t of std::string. I wrote this :

string::operator u_int32_t() const {return 0;}

But the compiler says :

error: specializing member ‘std::basic_string<char>::operator u_int32_t’ requires ‘template<>’ syntax


I used to using templates for a while, but here, I really don't know how to manage it. Any idea please ?
Conversion operators has to be class members. You can't add members outside the class definition so it's not possible to do what you are trying to do.
Last edited on
Thanks Peter87
Topic archived. No new replies allowed.