Boost logo

Boost :

Subject: [boost] [concept] concept-based overloading (N2081)
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2010-05-27 13:38:57


Hello all,

How do I use Boost.ConceptCheck and/or Bosot.EnableIf to implement
concept-based overloading (as discussed in N2081)?

For example, from N2081, the following functions are selected based on
`Iter` matching one of the two specified concepts:

    template<InputIterator Iter> // proposed concept syntax (not C++)
    void advance(Iter& x, Iter::distance_type n) {
        while (n > 0) { ++x; --n; }
    }

    template<BidirectionalIterator Iter> // proposed concept syntax (not C++)
    void advance(Iter& x, Iter::distance_type n) {
        if (n > 0) while (n > 0) { ++x; --n; }
        else while (n < 0) { --x; ++n; }
    }

How do I program this in C++ using Boost libraries?

N2081 briefly mentions this can be done in C++ using SFINAE, etc. I
think I could use `enable_if` if I had some sort of
`is_input_iterator` metafunction... Please just point me to the
documentation if this has already been addressed there.

Thank you very much.

-- 
Lorenzo

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk