Boost logo

Boost Users :

Subject: Re: [Boost-users] [Multi-Index] has_index<BMI,TAG> meta-function
From: Joaquin M Lopez Munoz (joaquin_at_[hidden])
Date: 2009-07-17 10:07:35


Dominique Devienne <ddevienne <at> gmail.com> writes:

>
> On Tue, Jul 14, 2009 at 5:49 PM, JOAQUIN M. LOPEZ MUÑOZ<joaquin <at> tid.es>
>
> One last question tonight :)

Sorry it's been a little later than that. I've been
offline for the last couple of days.
 
> Similarly to how I can now statically enable/disable code based on
> which index is implemented by a BMI, can one also change that code
> based on whether the index is unique vs non-unique? Or ordered vs
> hashed? [...]

Use index_specifier_type_list instead of index_type_list
(differences explained at http://tinyurl.com/nwe27r ) and
resort to something like this:

  template<typename IndexSpecifier>
  struct is_unique_index:boost::mpl::false_{};

  template<typename TagList,typename KeyFromValue,typename Compare>
  struct is_unique_index<
    boost::multi_index::ordered_unique<TagList,KeyFromValue,Compare>
>:boost::mpl::true_{};

  template<typename TagList,typename KeyFromValue,typename Hash,typename Pred>
  struct is_unique_index<
    boost::multi_index::hashed_unique<TagList,KeyFromValue,Hash,Pred>
>:boost::mpl::true_{};

and similarly for ordered vs hashed.

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