We use boost.any as the carrier type for a type-safe tagged variadic container. Here's what that means:
We have a "raft" object, which travels through a set of filters. When a filter wants to add data to the raft, it can do something like this:
raft.addTaggedData<ETag1>(3.0);
raft.addTaggedData<ETag2>("a string")`;
std::string str = raft.getTaggedData<ETag2>();
int a = raft.getTaggedData<ETag1>(); // <-- Compile error
Where ETag1
and ETag2
are members of an enum, and we use a traits template to map tags to types.
Tthe raft class is using a list
of pair<ETagType, boost::any>
as a backing store. Boost.any saved us the pain of managing raw buffers for various types.