
On Tue, Aug 25, 2009 at 10:12 PM, Steven Watanabe
AMDG
Ryan McConnehey wrote:
I have a sequence of types defined with the Loki library. I believe the equivalent would be boost::mpl::vector. The sequence is used to cause compile time asserts for unsupported types being passed to template functions. Boost variant can be created with a given list of types.
typedef boost::variant< int, std::string, short, long > type_list; |
| Is it possible to create a variant from a sequence by either passing the sequence or iterating through each value in the sequence? This would reduce the code duplication of having one sequence for assert checking and the other for variants. Use the metafunction boost::make_variant_over.
I doubt Boost.Variant is the best choice for this. You say a template function to enforce types, I would say Boost.Enable_if combined with Boost.Type_traits and Boost.MPL would make it real easy.