wxWidgets / wxWidgets

Cross-Platform C++ GUI Library
https://www.wxwidgets.org/
6.06k stars 1.76k forks source link

std::bind2nd is deprecated and doesn't compile anymore with c++17 #18458

Closed wxtrac closed 5 years ago

wxtrac commented 5 years ago

Issue migrated from trac ticket # 18458

component: base | priority: normal | resolution: invalid

2019-08-07 07:40:11: ufospoke created the issue


I tried to compile wxWidgets with -std=c++17.

The reason it is failing with clang is that std::bind2nd was deprecated in C++14 and removed in C++17. The other removed features are not used in wxWidgets and std::bind2nd is used only 2 times in a single file src/common/arrstr.cpp.

The easiest would be to replace it by a lambda but this is post C++11 and I suspect we would like to keep compiling with C++03.

Here is an example of a workaround used in the same file:

void wxArrayString::Sort(CompareFunction function)
{
    std::sort(begin(), end(),
#if __cplusplus >= 201103L
              [function](const wxString& s1, const wxString& s2)
              {
                  return function(s1, s2) < 0;
              }
#else // C++98 version
              wxStringCompare(function)
#endif // C++11/C++98
             );
}

We could use the same trick here.

wxtrac commented 5 years ago

2019-08-07 21:07:08: ufospoke commented


I'm surprised because this was supposed to be fixed by #18319.

wxtrac commented 5 years ago

2019-08-07 21:25:55: ufospoke changed status from new to closed

2019-08-07 21:25:55: ufospoke set resolution to invalid

2019-08-07 21:25:55: ufospoke commented

Sorry, this is my fault. It is fixed but bind2nd is still in the file so I just need to test the latest source from git. My apologize. F