Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-09-22 13:06:22


From: "John Max Skaller" <skaller_at_[hidden]>
> Daryle Walker wrote:
> >
> > 1. Some types in Boost items involve a std::pair with both template
> > parameters the same type. We could compact this somehow. Too bad we
can't
> > do:
> >
> > template < typename T >
> > typedef std::pair<T,T> doublet;
> >
> > I guess we have to make a class template that inherits from std::pair
and/or
> > uses special conversions.
>
> This is a fundamental construction, its correct name
> is 'the diagonal functor', represented by the Greek symbol Delta.
> [There is a also a dual 'codiagnoal functor' represented by
> an upside-down delta, it eliminates the case of a two alternatives
> of the same type]

[...]

> extract< [1,3,4,9,6], T1, T2, .. >
>
> which forms
>
> tuple<T1, T3, T4, T9, T6>
>
> This can actually be done I think, using primes and an integer
> argument (so that n = 2*^p1 * 3* p2 * 5^p3 .., and one can
> find p1, p2, p3 by factorising. This would be fun to do with
> templates .. :-]

It can be done but what's the motivation?

The conceptual 'type pair' (T, U) and its special case (T, T) are one thing,
std::pair<T, U> is another. Example:

template<class U, class T> U some_cast(T const & t);

The case where T == U obviously deserves special attention, but there's no
std::pair in sight.

--
Peter Dimov
Multi Media Ltd.

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