Specialize template is_string
I have a class that overloads a lot of members for different types as
follows:
template<typename T, typename Allocator>
Stream& operator << (Stream &Destination, const std::list<T, Allocator>
&Value)
template<typename T, typename Allocator>
Stream& operator << (Stream &Destination, const std::vector<T, Allocator>
&Value)
And now I'm trying to specialize it for strings.. I created an is string
using:
...
...
template<>
struct is_string<std::string> : std::true_type {};
...
...
and then I want to make it specialized as follows:
template<typename T = typename is_literal<T>::value_type> //How?
Stream& operator << (Stream &Destination, const typename
is_literal<T>::value_type &Value)
{
std::cout<<"HERE";
return Destination;
}
//I can do:
template<typename T = std::string> //works fine.
Stream& operator << (Stream &Destination, const typename
is_literal<T>::value_type &Value)
{
std::cout<<"HERE";
return Destination;
}
How can I fix the string one so that it works for all string types so that
T is whatever string type passed?
No comments:
Post a Comment