Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-02-08 09:53:49


----- Original Message -----
From: "rogeeff" <rogeeff_at_[hidden]>
>
> There is one small flaw with current implementation: it could lie
> sometimes about resulting iterator category. Does anybody know
> elegant way to deduce most restrictive category of two provided?

#include <boost/detail/select_type.hpp>

// needs workarounds for codewarrior 7
template <class C1, class C2>
struct most_restrictive
{
    BOOST_STATIC_ASSERT((is_convertible<C1,C2>::value ||
is_convertible<C2,C1>::value));

    typedef typename detail::if_true<
        is_convertible<C1,C2>::value
>::template then
    <
        C2
 // else
        , C1
>::type type;
};


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