Boost logo

Boost :

From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2001-11-20 14:02:57

Emily Winch wrote:
> > Ok, I agree in this case one can use super_subclass<T,
> > U>::type (can you say "pretty ugly")...
> Not half as ugly as ALL UPPERCASE :)
> Here is an argument that might be relevant.
> SUPER_SUBCLASS is essentially a function operating on types,
> that takes two types and returns a type.
> Functions are useful for all sorts of things including passing them
> to other functions for evaluating later.
> Making SUPER_SUBCLASS a macro would remove that option.

That's the agrument that I was going to bring too :).

> At the moment I can't think of a practical situation in which
> it would be useful to pass super_subclass as a template template
> parameter, but it might be worth keeping in mind.

Here is one example:

    #include "boost/mpl/remove_if.hpp"
    #include "boost/mpl/type_list.hpp"
    #include "boost/mpl/make_fun.hpp"
    #include "boost/mpl/bind.hpp"
    #include "boost/type_traits/same_traits.hpp"
    #include "boost/type_traits/conversion_traits.hpp"

    namespace mpl = boost::mpl;

    template<typename T1, typename T2>
    struct super_subclass
        BOOST_STATIC_CONSTANT(bool, value = (
             boost::is_convertible<T2 const*, T1 const*>::value
          && boost::is_same<T1 const*, void const*>::value
    typedef mpl::type_list<...> types; // something meaningful :)
    typedef mpl::remove_if<
        , mpl::bind1st<mpl::make_f_xy<super_subclass>,T>
>::sequence result;

I am not claim that the above code has any practical value, of course :).
But if you replace 'remove_if' with 'find_if', or 'count_if', or 'sort',
etc. (see boost/mpl for the complete list of the algorithms :) - it might.

BTW, Emily, I've read you paper
(, and I am impressed both by the
work you did, and by the fact how close an independent work of two people
can be ;). As Dave has already mentioned, a little while ago I too wrote a
couple of simple tuple extensions
(, some of which, as I
know now, are scarily close to what your paper describes :). Of course, you
work is much more thought-out than mine (I've spent only a few days on the
whole topic :), but if you are interested to cooperate - I would be more
than happy!


Boost list run by bdawes at, gregod at, cpdaniel at, john at