Boost logo

Boost Users :

Subject: Re: [Boost-users] [Multi-Index] has_index<BMI,TAG> meta-function
From: Dominique Devienne (ddevienne_at_[hidden])
Date: 2009-07-17 11:07:42


On Fri, Jul 17, 2009 at 9:07 AM, Joaquin M Lopez Munoz<joaquin_at_[hidden]> wrote:
> 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.

Thanks. Partial specialization I understand at least :) Although
that's the first time I see the specialization having more template
arguments than the base template, and that threw me off initially, but
I see there's still a single template argument in is_unique_index,
which happens to be a template itself. Thanks a bunch. --DD


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