|
Boost Users : |
Subject: Re: [Boost-users] [Multi-Index] has_index<BMI,TAG> meta-function
From: Dominique Devienne (ddevienne_at_[hidden])
Date: 2009-07-14 18:37:28
On Tue, Jul 14, 2009 at 5:11 PM, JOAQUIN M. LOPEZ MUÑOZ<joaquin_at_[hidden]> wrote:
>> I'd like to use enable_if/disable_if with a meta-function that
>> determines whether a given multi-index container has a given tagged index.
> You can use this:
>
> template<typename Index>
> struct tag_list
> {
> typedef typename Index::tag_list type;
> };
>
> template<typename MultiIndexContainer,typename Tag>
> struct has_index:
> boost::mpl::contains<
> boost::mpl::transform_view<
> typename MultiIndexContainer::index_type_list,
> boost::mpl::contains<tag_list<boost::mpl::_>,Tag>
> >,
> boost::mpl::true_
> >
> {};
Thanks. This appears to be working for me (i.e. I'm getting to errors
past this code, which I'll need to clear before I can fully test it).
My own attempt below fails on tag_list precisely, and I don't
understand why. Your post came just in time :) Although if someone can
point where mine went wrong, I'm still interested.
Once again, thank you Joaquín! --DD
error C2039: 'tag_list' : is not a member of
'boost::mpl::vector3<T0,T1,T2>' boost\multi_index\detail\has_tag.hpp 31
error C2146: syntax error : missing ',' before identifier
'tag_list' boost\multi_index\detail\has_tag.hpp 31
error C2065: 'tag_list' : undeclared
identifier boost\multi_index\detail\has_tag.hpp 31
error C2955: 'boost::mpl::contains' : use of class template requires
template argument list boost\multi_index\detail\has_tag.hpp 32
using namespace boost;
using boost::multi_index::detail::has_tag;
template<typename BMI, typename TAG>
struct has_index {
typedef typename BMI::index_type_list index_type_list;
typedef typename mpl::end<index_type_list>::type index_type_list_end;
typedef typename has_tag<TAG>::template
apply<index_type_list>::type iter;
BOOST_STATIC_CONSTANT(bool, value =!(is_same<iter,
index_type_list_end>::value));
};
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net