next up previous contents index
Next: pack/unpack Up: Object Reflection Previous: Excluding particular members from   Contents   Index

STL containers

Container support for standard STL containers is handled automatically by the standard descriptors. To extend the support to custom containers, it is necessary to inform classdesc that your custom type is a container, and that is done via two type traits: is_sequence and is_associative_container, which handle these two concepts from the standard library. The standard sequence containers are vector, deque and list, and the standard associative containers are set, map, and the multi_ and unordered_ variants of those.

To enable support for your custom container, eg one that conforms to the sequence concept, define a type trait for your custom container somewhere prior to classdesc\_epilogue.h being included. For example:

namespace classdesc
  template <> struct is_sequence<MyContainer>: public true_type {};

If you wish to support containers in your own custom descriptor, you should ideally not refer to specific types, but use these type traits to write truly generic code. This involves quite advance metaprogramming skills, but you can use the file pack_stl.h as an exemplar.

Russell Standish 2016-09-02