[boost] Re: please read! min/max guidelines
by Thomas Witt other posts by this author
Feb 29 2004 3:03PM messages near this date
[boost] Re: please read! min/max guidelines
|
[boost] Re: please read! min/max guidelines
Eric Niebler wrote:
> Paul Mensonides wrote:
>
> > The only way to
> > "have-your-cake-and eat-it-too" in the presence of macros like min/max
> > is to
> > prevent them from expanding manually with
> > BOOST_PREVENT_MACRO_SUBSTITUTION.
> >
> > int main() {
> > using std::min;
> > min BOOST_PREVENT_MACRO_SUBSTITUTION(1, 2);
> > return 0;
> > }
> >
> > This yields ADL and local context (which includes std::min if necessary).
>
>
> Thanks, Paul. That's correct. boost::std_min is defined as follows:
>
> template< typename T >
> inline T const & std_min( T const & a, T const & b ) {
> using std::min;
> return min BOOST_PREVENT_MACRO_SUBSTITUTION ( a, b );
> }
>
> So a call to boost::std_min is essentially an unqualified call to min,
> with a using directive to pull in std::min. Since it's an unqualified
> call, ADL can also pull in additional overloads from different namespaces.
Maybe it's worth mentioning that it is only usefull for use in the
namespace boost. IIUC there is no lookup in the local namespace and
additional lookup in boost. I.e. it's not quite an unqualified call when
used outside boost.
Thomas
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Thread:
Dave Harris
Edward Diener
Edward Diener
Eric Niebler
Daryle Walker
Eric Niebler
Thomas Witt
Paul Mensonides
Thomas Witt
David Abrahams
Eric Niebler
Jeff Garland
Beman Dawes
Paul Mensonides
Eric Niebler
Daniel Frey
Thomas Witt
Eric Niebler
Max Motovilov
Edward Diener
Eric Niebler
John Maddock
Eric Niebler
David Abrahams
Eric Niebler
Daryle Walker
Eric Niebler
Paul Mensonides
David Abrahams
Eric Niebler
John Maddock
Eric Niebler
Eric Niebler
Guillaume Melquiond
Eric Niebler
Guillaume Melquiond
Eric Niebler
Guillaume Melquiond
Eric Niebler
Alberto Barbati
Eric Niebler
Eric Niebler
David Abrahams
John Maddock
Eric Niebler
Beman Dawes
John Maddock
Eric Niebler
Dan W.
|