I have a string class implemented as a class template like:
template <class T>
class HGStringBasic
{
//...
public:
//...
HGStringBasic& operator += (const T* rhs)
{
//...
}
template <class U, std::enable_if_t<std::is_same<U, char>::value>* = nullptr>
HGStringBasic& operator += (const U* rhs)
{
//...
}
//...
}
The code is C++ 11 standard conform. The goal was to implement an overloaded operator += (const char) which is only used, if class T of the template is for instance "wchar_t".
I would like to know, how i can achieve the same result if the compiler don't understand C++11.
UPDATE:
Sry i'm new to stackoverlow and i haven't seen, that my code wasn't fully shown in the code block. I have now updated my code sniped so far.
I have also corrected a mistake within the template argument list from the template function operator += (), TartanLlama you're absolutly right, is_same<T, char>
must be is_same<U, char>
.
std::enable_if
even work? I would have thought failures would be hard asT
isn't in the immediate context of the function declaration. – TartanLlama Oct 16 '15 at 14:47