Reputation: 3307
I am refactoring a serialization library in my project so that it compiles with
-std=c++11
and want to identify if an object is a STL container, e.g.
is_stl_deque<T>::value
is_stl_list<T>::value
is_stl_vector<T>::value
is_set<T>::value
is_map<T>::value
is_pair<T>::value
is_sequence<T>::value
Is there any boost trait to check if an object is a STL container ?
If not (I couldn't find any), how can I implement one ?
Upvotes: 1
Views: 280
Reputation: 137330
I don't know if there's anything in boost, but the things in your list are easily implementable with partial specialization:
template<class T>
struct is_vector : std::false_type { };
template<class T, class Alloc>
struct is_vector<std::vector<T, Alloc>> : std::true_type { };
Upvotes: 7