(const) char[] is a plain C string type too

and it's size is not known, so it cannot be taken as a string literal
This commit is contained in:
Luboš Luňák 2012-03-29 07:39:03 +02:00
parent 175dc9fcc6
commit dbf238ba0a

View file

@ -50,7 +50,8 @@ namespace internal
{
/*
These templates use SFINAE (Substitution failure is not an error) to help distinguish the various
plain C string types: char*, const char*, char[N] and const char[N]. There are 2 cases:
plain C string types: char*, const char*, char[N], const char[N], char[] and const char[].
There are 2 cases:
1) Only string literal (i.e. const char[N]) is wanted, not any of the others.
In this case it is necessary to distinguish between const char[N] and char[N], as the latter
would be automatically converted to the const variant, which is not wanted (not a string literal
@ -90,6 +91,16 @@ struct NonConstCharArrayDetector< char[ N ], T >
{
typedef T Type;
};
template< typename T >
struct NonConstCharArrayDetector< char[], T >
{
typedef T Type;
};
template< typename T >
struct NonConstCharArrayDetector< const char[], T >
{
typedef T Type;
};
template< typename T1, typename T2 >
struct ConstCharArrayDetector