Bug #2612
openAmbiguity between std::bind and std::tr1::bind
0%
Description
As I mentioned in https://projects.vdr-developer.org/issues/2611, there are some changes to std::tr1::bind coming in GCC 11 which cause compilation errors in your code:
tasks.cpp: In member function ‘void vdrlive::TaskManager::DoScheduledTasks()’:
tasks.cpp:248:83: error: call of overloaded ‘bind(void (vdrlive::Task::*)(), const std::_Placeholder<1>&)’ is ambiguous
248 | for_each( m_taskQueue.begin(), m_taskQueue.end(), bind(&Task::Action, _1 ) );
| ^
In file included from stdext.h:6,
from tasks.cpp:4:
/tmp/installed/include/c++/11.0.0/tr1/functional:1457:5: note: candidate: ‘std::tr1::_Bind<typename std::tr1::_Maybe_wrap_member_pointer<_Tp>::type(_ArgTypes ...)> std::tr1::bind(_Functor, _ArgTypes ...) [...]’
1457 | bind(_Functor __f, _ArgTypes... __args)
| ^~~~
In file included from /tmp/installed/include/c++/11.0.0/tr1/functional:34,
from stdext.h:6,
from tasks.cpp:4:
/tmp/installed/include/c++/11.0.0/functional:789:5: note: candidate: ‘typename std::_Bind_helper<std::__is_socketlike<_Func, typename std::decay<_Tp>::type>::value, _Func, _BoundArgs ...>::type std::bind(_Func&&, BoundArgs&& ...) [...]’
789 | bind(_Func&& __f, _BoundArgs&&... __args)
| ^~~~
This happens because GCC defaults to modern C++ versions, which means std::bind is declared as well as std::tr1::bind. In GCC 11 the TR1 placeholders such as std::tr1::placeholders::_1 are now the same type as the C++11 placeholders such as std::placeholders::_1 and so the unqualified call to bind(..., _1) finds std::bind by Argument-Dependent Lookup as well as finding std::tr1::bind because of the using-declaration at the top of tasks.cpp.
Replacing all use of TR1 with the C++11 equivalents (as https://projects.vdr-developer.org/issues/2611 suggested) would be one fix. I think a minimal fix for the compilation error would be to just use std::bind in tasks.cpp e.g.
--- vdr-plugin-live-e582514ede475574842b44ca6792335ff141172d/tasks.cpp~ 2020-12-08 11:20:07.277317477 +0000
+++ vdr-plugin-live-e582514ede475574842b44ca6792335ff141172d/tasks.cpp 2020-12-08 11:20:11.112311582 +0000
@@ -16,8 +16,13 @@
namespace vdrlive {
using std::for_each;
+#if __cplusplus >= 201103L
+using std::bind;
+using namespace std::placeholders;
+#else
using std::tr1::bind;
using namespace std::tr1::placeholders;
+#endif
const char* NowReplaying()
{
No data to display