Skip to content

Instantly share code, notes, and snippets.

@simonlynen
Created August 8, 2015 21:59
Show Gist options
  • Save simonlynen/b29750e69e6629ddcfd3 to your computer and use it in GitHub Desktop.
Save simonlynen/b29750e69e6629ddcfd3 to your computer and use it in GitHub Desktop.
template<typename T>
struct HasConstIterator {
private:
typedef char Yes;
typedef struct {
char array[2];
} No;
template<typename C> static Yes Test(typename C::const_iterator*);
template<typename C> static No Test(...);
public:
static const bool value = sizeof(Test<T>(0)) == sizeof(Yes);
typedef T type;
};
template<typename T>
struct IsContainer : std::integral_constant<bool, HasConstIterator<T>::value> {
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment