|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2008-07-11 14:26:13
on Fri Jul 11 2008, "Robert Jones" <robertgbjones-AT-gmail.com> wrote:
> On Fri, Jul 11, 2008 at 7:08 PM, Steven Watanabe <watanabesj_at_[hidden]>
> wrote:
>
>>
>> Robert Jones wrote:
>>
>>> I'm sorry, I'm not quite following! I understand ADL in general, but not
>>> how
>>> it applies
>>> specifically here. What overloading is being found/not found by ADL in
>>> this
>>> context?
>>>
>>>
>>
>> The overload of operator<< for std::pair is not found by Boost.Lambda.
>
> This much I have discovered painfully by trial and error - the bit I
> don't understand is why!
Because was not in scope at the point where the lambda's operator() is
defined, and it isn't defined in a namespace associated with any of the
arguments you passed to it (ostream and std::pair<...>). Those are the
lookup rules for unqualified calls in templates.
namespace bll
{
template <class T>
void f(T x)
{
// looks backwards from this point for op<< defined in
// namespaces :: and ::bll::. Looks backwards from the
// point of instantiation for op<< defined in any
// namespaces associated with T.
x << x;
}
};
I think I got that right.
> Also, it would be very handy if you can suggest a method of achieving
> the effect I'm looking for.
Depends what effect that is; it may or may not be achievable.
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk