Boost logo

Boost :

From: Maciej Sobczak (maciej_at_[hidden])
Date: 2002-07-25 04:15:19

Victor A. Wagner, Jr. wrote:
> only one small nit...see below

>> sort(v.begin(), v.end(), oper_on_mem(&S::a, less<int>()));
> it's a shame you have to say <int> here.... it's deducible from S::a

Yes, and the oper_on_mem function could do the deduction and provide the
template parameter to the functor it is given. The problem is that this
way you would limit its usage only to templates and only to those that
accept one template parameter. What about other functors?

The ones that are not templates:

class MyComparator;

Or the ones that accept more than one template parameter:

template <typename T, class SomePolicy>
class MyComparator;

and so on.

Besides this, are you ashamed writing this?:

vector<int> v;
sort(v.begin(), v.end(), greater<int>());

I'm not. ;-)

The int could be deducted here, too - but the flexibility of such an
algorithm would be greatly limited then.


Maciej Sobczak

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