I have a simple SFINAE script to distinguish standard containers like std::map
:
template <typename Container> struct HasKeyType : sfinae_test {
FROM
struct sfinae_test { typedef char Yes; typedef long No; static void* const null; };
When I create an instance using HasKeyType<std::vector<int> >::value
, I get
(A) error: no type named 'key_type' in 'class std::vector<int>' (B) error: invalid use of incomplete type 'struct HasKeyType<std::vector<int> >' (C) error: declaration of 'struct HasKeyType<std::vector<int> >'
I am completely at a dead end. Why is HasKeyType
incomplete, and why does SFINAE not work?
I get similar errors with (B)
and (C)
if I create an instance of HasKeyType<std::map<int,float> >
, which actually has the key type ( int
).
g ++ version: 4.5.2 (yes, I know this is old)
source share