Boost logo

Boost :

From: Steven Watanabe (steven_at_[hidden])
Date: 2006-11-27 18:01:03


AMDG

Multimethods are unsafe unless
a. all combinations are valid
b. all the types involved are known at the same time somewhere
c. a reasonable default exist when no matching function can be found

Variant handles case a.
case c is true for comparisons

case b can be handled something like this
typedef any_tuple<_1, _1, _2,
  where_<random_access_iterator<_1>, callable<_2, bool(deref_result<_1>,
deref_result<_1>)> > > sort_args;
void sort_impl(mpl::at<sort_args, _1>::type&, mpl::at<sort_args,
_1>::type&, mpl::at<sort_args, _2>::type&);
template<class Iter, class F>
void sort(Iter begin, Iter end, F f) {
    sort_args args(begin, end, f);
    sort_impl(get<0>(args), get<1>(args), get<2>(args));
}

Would such a class be useful?
Any better ideas for the interface?

The big problem is the amount of metaprograming needed.
10 operations were more than msvc 7.1 could handle with
my version of dynamic_any::any<> and this is much worse.

In Christ,
Steven Watanabe


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