[boost] [bind] placeholders in namespace ::

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[boost] [bind] placeholders in namespace ::

lcaminiti
Hello all,

Do you know in which namespace Boost.Bind placeholders are actually defined?

#include <boost/bind.hpp>
#include <iostream>

void f ( int a, int b )
{
    std::cout << a << " " << b << std::endl;
}

int main ( )
{
    int x = 10;
    boost::bind(f, 5, ::_1)(x);
    return 0;
}

From the example above, the docs, and the source code, I am pretty sure Boost.Bind placeholders are defined in the unnamed namespace :: ... why? Isn't it a bad practice for a library to pollute the unnamed namespace?

Thanks for the clarification.
--Lorenzo
Reply | Threaded
Open this post in threaded view
|

Re: [bind] placeholders in namespace ::

Robert Jones-2
On Mon, Oct 24, 2011 at 11:36 PM, lcaminiti <[hidden email]> wrote:

>
> >From the example above, the docs, and the source code, I am pretty sure
> Boost.Bind placeholders are defined in the unnamed namespace :: ... why?
> Isn't it a bad practice for a library to pollute the unnamed namespace?
>
>
Yes, you are correct, they are, and yes you are correct it's almost
certainly a mistake.
This comes up time and time again, and I think it's fair to say it's about
the most
recognized misjudgement in Boost, but it's also water under the bridge now,
and
would be massively disruptive to change it. I guess at the time _1 seemed a
pretty innocent token token to put in the global namespace, and of course
it does allow you to use placeholders unqualified.

When Boost.Bind was more or less adopted as std.bind, this was changed.

- Rob.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [bind] placeholders in namespace ::

lcaminiti
Robert Jones-2 wrote
On Mon, Oct 24, 2011 at 11:36 PM, lcaminiti <[hidden email]> wrote:

>
> >From the example above, the docs, and the source code, I am pretty sure
> Boost.Bind placeholders are defined in the unnamed namespace :: ... why?
> Isn't it a bad practice for a library to pollute the unnamed namespace?
>
>
Yes, you are correct, they are, and yes you are correct it's almost
certainly a mistake.
This comes up time and time again, and I think it's fair to say it's about
the most
recognized misjudgement in Boost, but it's also water under the bridge now,
and
would be massively disruptive to change it. I guess at the time _1 seemed a
pretty innocent token token to put in the global namespace, and of course
it does allow you to use placeholders unqualified.

When Boost.Bind was more or less adopted as std.bind, this was changed.
OK, it makes sense. (Maybe these historic reasons could be added to the docs to avoid further questioning...)

Thanks a lot.
--Lorenzo