
David Abrahams wrote:
Eric Niebler <eric@boost-consulting.com> writes:
Put the overload in an associated namespace of the type. Or for maximum portability, you could put the overload at global scope.
Really? If invoked from within a template, global scope overloads won't be found unless an argument is in the global namespace or the overloads happen to appear before the point of definition of the template.
That was the idea, yes.
If you want a way to make this portable, consider adding a dummy parameter that comes from namespace Boost and asking people to overload there (the Ramey trick).
I'm not sure how this helps on compilers that don't do ADL. This is a macro. BOOST_FOREACH(foo, bar) will expand to something that makes a non-qualified call to boost_foreach_has_cheap_copy *in the context of the BOOST_FOREACH invocation*. This could be any context, in any namespace. If I want this to work on compilers that don't do ADL, requiring people to make their overloads visible at global scope seems necessary, but I've likely overlooked something. -- Eric Niebler Boost Consulting www.boost-consulting.com