Boost logo

Boost Users :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2006-06-14 16:44:46


On Jun 14, 2006, at 3:58 PM, Steven E. Harris wrote:

> Peter Dimov <pdimov_at_[hidden]> writes:
>
>> One common problem of this kind is
>>
>> template< class T, class A = std::allocator<T> > class X;
>>
>> X<int> x;
>>
>> foo( x ); // searches std
>
> Given that this can be characterized as a problem, what's a "positive"
> example to illustrate the motivation for this rule? There must be
> something useful it's meant to enable. Or, rather, I hope there is.

For example the standard might create I/O for pair:

template <class T1, class T2>
ostream&
operator<<(ostream&, pair<T1, T2>);

Then you might also want to get more specialized behavior for
pair<MyNamespace::MyType, int> (in your own namespace). It would be
nice if when pair<MyNamespace::MyType, int> was given to operator<<
both namespace std and namespace MyNamespace were searched for viable
overloads.

-Howard


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net