Boost logo

Boost Users :

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


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 :(

Does anyone know how to implement it? Below how I'd like to use it. Thanks, --DD

struct ByName {};

template <class BMI> struct VCursor {
    virtual void filter_by_name(const string& name) {
        do_filter_by_name(name);
    }

private:

    void do_filter_by_name(
        const string& name,
        typename boost::enable_if<has_index<BMI, ByName> >::type* /*dummy*/ = 0
    ) {
        typedef typename BMI::template index<ByName>::type index_type;
        ...
    }
    void do_filter_by_name(
        const string& name,
        typename boost::disable_if<has_index<BMI, ByName> >::type* /*dummy*/ = 0
    ) {
        throw "no name index";
    }
};


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