Opened 7 years ago
Last modified 7 years ago
#11902 new Bugs
bind placeholder _1 is not defined
| Reported by: | Owned by: | Peter Dimov | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | bind |
| Version: | Boost 1.60.0 | Severity: | Problem |
| Keywords: | Cc: |
Description
bind placeholder _1 is not defined in version 1.60.0 .
Example
#include <boost/bind/bind.hpp>
int f(int a, int b) { return a + b; }
int main(void)
{
int x = 1;
int a = boost::bind(f, 5, _1)(x);
return 0;
}
Compiler output:
bind_error.cpp: In function ‘int main()’:
bind_error.cpp:11:29: error: ‘_1’ was not declared in this scope
int a = boost::bind(f, 5, _1)(x);
^
bind_error.cpp:11:29: note: suggested alternative:
In file included from /home/projekte/libwinforwiss/boost/boost_1_60_0/boost/bind/bind.hpp:2247:0,
from bind_error.cpp:1:
/home/projekte/libwinforwiss/boost/boost_1_60_0/boost/bind/placeholders.hpp:46:38: note: ‘boost::placeholders::_1’
BOOST_STATIC_CONSTEXPR boost::arg<1> _1;
Replacing _1 with boost::placeholders::_1 works for 1.60.0 , but not for 1.59.0.
Change History (3)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
| Component: | None → bind |
|---|---|
| Owner: | set to |
comment:3 by , 7 years ago
This is by design; from now on, #include <boost/bind/bind.hpp> defines _1 in namespace boost::placeholders without importing it into the global namespace, to avoid conflicts. For backward compatibility, #include <boost/bind.hpp> includes boost/bind/bind.hpp and does using namespace boost::placeholders;.
So, to make the code compile, either include boost/bind.hpp instead, or add using namespace boost::placeholders;.

I have the same problem, but only on Visual.