Reputation: 661
I notice that the typeid(T)
call provides a nice constexpr-compatible way to retrieve a unique identifier for a given class at compile-time. This is very useful, but I notice that relational operators between the type_info
objects which this yields are not enabled at compile-time. This makes sense, since the actual IDs may vary at runtime. However, I would like to impose an ordering between types such that:
This is very doable at compile-time by explicitly defining the IDs for each type. However, I was wondering if there is a more reasonable approach to generate compile-time, constexpr-compatible IDs per type which allow for relational operations.
Thanks!
Upvotes: 1
Views: 1422
Reputation: 62985
Summarizing comments:
boost::fusion::set<>
has the functionality you need, with metafunctions to mimic most algorithms in the standard library, including insertion and removal. All Fusion containers are completely stack-based, as all are simply tuples with algorithm metafunctions on top.
(Boost.Fusion overview here.)
Upvotes: 2