recursive variant with mpl::vector
Hello all, I'm trying to create a recursive variant over an MPL vector.<http://?shva=1#drafts/128ba01f42cb2169> attached is the code. I'm trying to add a templated function isType, which will return true if the type stored in variant is the type queried for or false otherwise. This doesn't work for recursive types. In the example, I expect the program outputs "Map Type" because the type stored in the variant is a map. but it says the type is not map. The problem is mpl::contains returns false for map type. (The type stored in mpl vector is boost::recursive_wrapper< map ... >, where as, I'm querying for map...). what is the way forward from here. Thanks, Surya.
Got it... typedef mpl::transform < VariantTypes, boost::unwrap_recursive <mpl::_1>
::type BaseVariantTypes ;
template <class T> struct variant_type : public mpl::if_ < typename mpl::contains <BaseVariantTypes, T>::type, valid_type<T>, invalid_type<T> >::type { }; Thanks, Surya On Fri, May 21, 2010 at 14:18, Surya Kiran Gullapalli < suryakiran.gullapalli@gmail.com> wrote:
Hello all, I'm trying to create a recursive variant over an MPL vector.<http://?shva=1#drafts/128ba01f42cb2169>
attached is the code.
I'm trying to add a templated function isType, which will return true if the type stored in variant is the type queried for or false otherwise.
This doesn't work for recursive types.
In the example, I expect the program outputs "Map Type" because the type stored in the variant is a map. but it says the type is not map.
The problem is mpl::contains returns false for map type. (The type stored in mpl vector is boost::recursive_wrapper< map ... >, where as, I'm querying for map...). what is the way forward from here.
Thanks, Surya.
participants (1)
-
Surya Kiran Gullapalli