I have is_string
defined as follow in my C++ code:
#include <string>
template <typename T>
struct is_string
{
static const bool value = false;
};
template <class T, class Traits, class Alloc>
struct is_string<std::basic_string<T, Traits, Alloc>>
{
static const bool value = true;
};
int main()
{
std::cout << is_string<std::string>::value << std::endl;
std::cout << is_string<std::wstring>::value << std::endl;
return 0;
}
It is true for both std::string
and std::wstring
.
But I need a predicate like this:
is_string<char, std::string>::value //to be true
is_string<char, std::wstring>::value //to be false
is_string<wchar_t, std::string>::value //to be false
is_string<wchar_t, std::wstring>::value //to be true
Is it possible to implement it?
std::true_type
/std::false_type
to shorten code.