Boost logo

Boost Users :

Subject: Re: [Boost-users] [Multi-Index] has_index<BMI,TAG> meta-function
From: JOAQUIN M. LOPEZ MUÑOZ (joaquin_at_[hidden])
Date: 2009-07-14 18:11:05


________________________________________
De: boost-users-bounces_at_[hidden] [boost-users-bounces_at_[hidden]] En nombre de Dominique Devienne [ddevienne_at_[hidden]]
Enviado el: martes, 14 de julio de 2009 23:18
Para: boost-users
Asunto: [Boost-users] [Multi-Index] has_index<BMI,TAG> meta-function

> 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.
>
> But I'm not having success writing has_index<BMI,TAG>, even looking at
> BMI's own index<Tag> meta-function :(

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_
>
{};

which BTW relies on the mistakenly undocumented nested type
tag_list that all indices are equipped with. I'll update the docs when
I find some time.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


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