The name is probably too vague, I will explain what I mean.
I am developing a helper library for working with encoded TLV values. In the library, each value contains a tag identifier, a tag type code, and a tag value in its own field type. Such a labeled container of values is implemented by a template class parameterized by the tag identifier and associated type (which declares the properties of the marked value). Now I want to make sure that one tag identifier is associated with only one tag, so that I could not create TLV values with the same tag identifiers, but with different data types. Thus, it is a kind of dictionary, verified only at compile time.
template<uint_t TagId, typename Trait>
struct TagBinder
{
enum { my_id = TagId };
};
I want to TagBinder<100, IntTrait>and TagBinder<100, BoolTrait>do not get together. I wonder if this is possible at all. Maybe something in boost MPL can be used? One thing I'm trying to avoid is macros. In addition, C ++ 11, unfortunately, cannot be.
Thank you in advance!
source
share