#include <type_traits>
template<class T>
class is_container{
typedef char (&two)[2];
template<class U> // non-const
static auto test(typename U::iterator*, int)
-> decltype(std::declval<U>().begin(), char());
template<class U> // const
static auto test(typename U::const_iterator*, long)
-> decltype(std::declval<U const>().begin(), char());
template<class>
static two test(...);
public:
static bool const value = sizeof(test<T>(0,0)) == 1;
};
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
int main()
{
std::cout << is_container<std::vector<std::string> >::value << ' ';
std::cout << is_container<std::list<std::string> >::value << ' ';
std::cout << is_container<std::set<std::string> >::value << ' ';
std::cout << is_container<std::map<std::string, std::string> >::value << '\n';
}
I2luY2x1ZGUgPHR5cGVfdHJhaXRzPgoKdGVtcGxhdGU8Y2xhc3MgVD4KY2xhc3MgaXNfY29udGFpbmVyewogIHR5cGVkZWYgY2hhciAoJnR3bylbMl07CgogIHRlbXBsYXRlPGNsYXNzIFU+IC8vIG5vbi1jb25zdAogIHN0YXRpYyBhdXRvIHRlc3QodHlwZW5hbWUgVTo6aXRlcmF0b3IqLCBpbnQpCiAgICAgIC0+IGRlY2x0eXBlKHN0ZDo6ZGVjbHZhbDxVPigpLmJlZ2luKCksIGNoYXIoKSk7CgogIHRlbXBsYXRlPGNsYXNzIFU+IC8vIGNvbnN0CiAgc3RhdGljIGF1dG8gdGVzdCh0eXBlbmFtZSBVOjpjb25zdF9pdGVyYXRvciosIGxvbmcpCiAgICAgIC0+IGRlY2x0eXBlKHN0ZDo6ZGVjbHZhbDxVIGNvbnN0PigpLmJlZ2luKCksIGNoYXIoKSk7CgogIHRlbXBsYXRlPGNsYXNzPgogIHN0YXRpYyB0d28gIHRlc3QoLi4uKTsKCnB1YmxpYzoKICBzdGF0aWMgYm9vbCBjb25zdCB2YWx1ZSA9IHNpemVvZih0ZXN0PFQ+KDAsMCkpID09IDE7Cn07CgojaW5jbHVkZSA8aW9zdHJlYW0+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxsaXN0PgojaW5jbHVkZSA8c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