Opened 5 years ago
Last modified 5 years ago
#13007 assigned Bugs
When BOOST_BIND_NO_PLACEHOLDERS is defined, framework.ipp seems to be missing an #include
Reported by: | Owned by: | Raffi Enficiaud | |
---|---|---|---|
Milestone: | Boost 1.65.0 | Component: | test |
Version: | Boost 1.64.0 | Severity: | Problem |
Keywords: | Cc: |
Description
Like the summary says, I think boost/test/impl/framework.ipp should simply have one additional #include <boost/bind/placeholders.hpp> so it works when BOOST_BIND_NO_PLACEHOLDERS is defined.
Change History (7)
comment:1 by , 5 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 5 years ago
Milestone: | To Be Determined → Boost 1.65.0 |
---|
comment:3 by , 5 years ago
comment:4 by , 5 years ago
Sorry for not being specific enough originally.
I can reproduce it on boost-1.64.0 if I use the headers-only include in your test program.
#include <boost/test/included/unit_test.hpp
It also happens if you define BOOST_BIND_NO_PLACEHOLDERS in boost/config/user.hpp and compile the standalone Boost.Test library.
comment:5 by , 5 years ago
Ok, thank you for the feedback. I am hesitating concerning the fix of forcing the include of the placeholders.hpp
even if the macro is defined. OTOH, the fact that this is working in case of non-header-only variant is also not coherent.
What is the use case of the BOOST_BIND_NO_PLACEHOLDERS
for you? I still do not understand why you would like to use this non-documented macro and what is the benefit.
When you define it, do you include std::
placeholders instead?
comment:6 by , 5 years ago
It seems that this only happens with some toolchains. For example, consider the following program, which works if BOOST_BIND_NO_PLACEHOLDERS
is defined, but fails to compile otherwise (at least with some toolchains):
//#define BOOST_BIND_NO_PLACEHOLDERS #include <boost/bind.hpp> #include <functional> #include <cstdio> using namespace std::placeholders; int main() { const auto g = std::bind(std::puts, _1); g("Hello, world!"); }
With gcc-4.9 (admittedly old, but still important for some targets):
$ g++ -Wall -std=c++11 -c -o foo.o foo.cc -I boost_1_64_0 foo.cc: In function ‘int main()’: foo.cc:10:39: error: reference to ‘_1’ is ambiguous const auto g = std::bind(std::puts, _1); ^ In file included from /usr/include/c++/4.9/memory:79:0, from boost_1_64_0/boost/config/no_tr1/memory.hpp:21, from boost_1_64_0/boost/get_pointer.hpp:14, from boost_1_64_0/boost/bind/mem_fn.hpp:25, from boost_1_64_0/boost/mem_fn.hpp:22, from boost_1_64_0/boost/bind/bind.hpp:26, from boost_1_64_0/boost/bind.hpp:22, from foo.cc:2: /usr/include/c++/4.9/functional:972:34: note: candidates are: const std::_Placeholder<1> std::placeholders::_1 extern const _Placeholder<1> _1; ^ In file included from boost_1_64_0/boost/bind/bind.hpp:2319:0, from boost_1_64_0/boost/bind.hpp:22, from foo.cc:2: boost_1_64_0/boost/bind/placeholders.hpp:46:38: note: constexpr const boost::arg<1> boost::placeholders::_1 BOOST_STATIC_CONSTEXPR boost::arg<1> _1; ^
Using an online version of gcc-7 at coliru.stacked-crocked.com, it fails in the same way. (I can't post a link or Trac calls this post spam).
I don't see this with modern clang, but gcc-7 is pretty new, so there still seems to be a reason to set BOOST_BIND_NO_PLACEHOLDERS
.
BTW, I thought I remembered BOOST_BIND_NO_PLACEHOLDERS
being documented in config/user.hpp
, but it seems I was mistaken about that, at least in 1.64.0.
Sorry, I am not able to reproduce the error:
works. Am I missing something? I am doing this on the current develop branch.