[bind] BOOST_BIND_NO_PLACEHOLDERS and unspecified-placeholder-type's
Hello, The non-documented BOOST_BIND_NO_PLACEHOLDERS macro suppresses the definition of (anonymous namespace)::_1, (anonymous namespace)::_2, etc., presumably to cope with potential clashes with other libs' placeholders such as Boost.Lambda's when in the presence of using directives. The problem with this is that using Boost.Bind without placeholder names requires writing code such as bind(f,boost::arg<1>(),boost::arg<2>()); but boost::arg<> is not documented!! (in fact, Boost.Bind synopsis explicitly defines _1, _2 etc. as having undocumented types unspecified-placeholder-type-1, unspecified-placeholder-type-2 and so on). Maybe Boost.Bind documentation can be changed so that BOOST_BIND_NO_PLACEHOLDERS and boost::arg<> are documented? Thank you, Joaquín M López Muñoz Telefónica Digital ________________________________ Este mensaje se dirige exclusivamente a su destinatario. Puede consultar nuestra política de envío y recepción de correo electrónico en el enlace situado más abajo. This message is intended exclusively for its addressee. We only send and receive email on the basis of the terms set out at: http://www.tid.es/ES/PAGINAS/disclaimer.aspx
AMDG On 03/24/2014 12:10 AM, Joaquín Mª López Muñoz wrote:
The non-documented BOOST_BIND_NO_PLACEHOLDERS macro suppresses the definition of (anonymous namespace)::_1, (anonymous namespace)::_2, etc., presumably to cope with potential clashes with other libs' placeholders such as Boost.Lambda's when in the presence of using directives. The problem with this is that using Boost.Bind without placeholder names requires writing code such as
bind(f,boost::arg<1>(),boost::arg<2>());
The other solution is to define your own placeholders. You just need to specialize boost::is_placeholder. In Christ, Steven Watanabe
Steven Watanabe
AMDG
On 03/24/2014 12:10 AM, Joaquín Mª López Muñoz wrote:
The non-documented BOOST_BIND_NO_PLACEHOLDERS macro suppresses the definition of (anonymous namespace)::_1, (anonymous namespace)::_2, etc., presumably to cope with potential clashes with other libs' placeholders such as Boost.Lambda's when in the presence of using directives. The problem with this is that using Boost.Bind without placeholder names requires writing code such as
bind(f,boost::arg<1>(),boost::arg<2>());
The other solution is to define your own placeholders. You just need to specialize boost::is_placeholder.
Same problem: boost::is_placeholder is not documented anywhere AFAICS, nor is the fact that boost::bind uses it to determine what's a placeholder and what's not. So, it's just a documentation issue --I'm perfectly fine with using boost::arg<N>() or whatever provided it's the documented way to go. Thank you, Joaquín M López Muñoz Telefónica Digital
Joaquín Mª López Muñoz wrote:
Hello,
The non-documented BOOST_BIND_NO_PLACEHOLDERS macro suppresses the definition of (anonymous namespace)::_1, (anonymous namespace)::_2, etc., presumably to cope with potential clashes with other libs' placeholders such as Boost.Lambda's when in the presence of using directives.
I think that the presumption is incorrect. If my memory serves, the intent of BOOST_BIND_NO_PLACEHOLDERS was not to cope with _1 clashes, but with various other problems caused by their definitions, such as, for instance, not working with precompiled headers, code bloat caused by their repeat definition in every translation unit, and so on. So people who would rather not modify their Boost installation were able to (globally, at project level) suppress the definitions and add their own. If you were looking at the macro as a way to enable a library header to avoid _1 collisions, it will not work. User code which includes both your library header and then boost/bind.hpp and tries to use _1 will break, as the second inclusion of bind.hpp will do nothing and the placeholders will remain undefined.
The problem with this is that using Boost.Bind without placeholder names requires writing code such as
bind(f,boost::arg<1>(),boost::arg<2>());
but boost::arg<> is not documented!! (in fact, Boost.Bind synopsis explicitly defines _1, _2 etc. as having undocumented types unspecified-placeholder-type-1, unspecified-placeholder-type-2 and so on).
The synopsis is correct - the placeholders are currently not of type arg<I> half of the time, depending on the compiler; arg<I>(*)() is used instead. arg<I> always works as a placeholder though.
Maybe Boost.Bind documentation can be changed so that BOOST_BIND_NO_PLACEHOLDERS and boost::arg<> are documented?
I'm a bit reluctant to do that. The macro, in particular, will likely go away once the placeholders finally move to a namespace. boost::arg<> will probably work for all eternity, but there is a documented way to define placeholders, as Steven notes.
Peter Dimov
Joaquín Mª López Muñoz wrote:
Hello,
The non-documented BOOST_BIND_NO_PLACEHOLDERS macro suppresses the definition of (anonymous namespace)::_1, (anonymous namespace)::_2, etc., presumably to cope with potential clashes with other libs' placeholders such as Boost.Lambda's when in the presence of using directives.
I think that the presumption is incorrect.
Yes, you're right. The rest of th argument remains the same, though.
Maybe Boost.Bind documentation can be changed so that BOOST_BIND_NO_PLACEHOLDERS and boost::arg<> are documented?
I'm a bit reluctant to do that. The macro, in particular, will likely go away once the placeholders finally move to a namespace. boost::arg<> will probably work for all eternity, but there is a documented way to define placeholders, as Steven notes.
But this is not documented either: unless I'm mistaken, Boost.Bind docs don't do any mention to boost::is_placeholder. Joaquín M López Muñoz Telefónica Digital
participants (4)
-
Joaquin M Lopez Munoz
-
Joaquín Mª López Muñoz
-
Peter Dimov
-
Steven Watanabe