As I said, it will match string and you should check const_iterator instead. Even if you get it to exclude basic_string I think the danger of your method is that it always has the possibility of matching something that defines a begin(), end() and const_iterator but shouldn't be treated as a container.

To distinguish between pair and others, you'd probably need to use the value_type typedef of a container.