Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error on GCC 12.2.1, ptr_fun is deprecated #82

Open
AzP opened this issue Mar 1, 2023 · 0 comments · May be fixed by #85
Open

Compilation error on GCC 12.2.1, ptr_fun is deprecated #82

AzP opened this issue Mar 1, 2023 · 0 comments · May be fixed by #85

Comments

@AzP
Copy link
Contributor

AzP commented Mar 1, 2023

There is currently a compilation error on GCC 12.2.1, for ptr_fun is deprecated.

/tmxparser/src/TmxUtil.cpp:49:93: error: ‘std::pointer_to_unary_function<_Arg, _Result> std::ptr_fun(_Result (*)(_Arg)) [with _Arg = int; _Result = int]’ is deprecated: use 'std::function' instead [-Werror=deprecated-declarations]
   49 |         s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
      |                                                                       ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/functional:49,
                 from /home/peter/diverse/programmering/opengl/tmxparser/src/TmxUtil.cpp:31:
/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/stl_function.h:1126:5: note: declared here
 1126 |     ptr_fun(_Result (*__x)(_Arg))
      |     ^~~~~~~
/home/peter/diverse/programmering/opengl/tmxparser/src/TmxUtil.cpp:49:70: error: ‘constexpr std::unary_negate<_Predicate> std::not1(const _Predicate&) [with _Predicate = pointer_to_unary_function<int, int>]’ is deprecated: use 'std::not_fn' instead [-Werror=deprecated-declarations]
   49 |         s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
      |                                                             ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/stl_function.h:1046:5: note: declared here
 1046 |     not1(const _Predicate& __pred)
      |     ^~~~
/home/peter/diverse/programmering/opengl/tmxparser/src/TmxUtil.cpp: In function ‘std::string& Tmx::rtrim(std::string&)’:
/home/peter/diverse/programmering/opengl/tmxparser/src/TmxUtil.cpp:55:84: error: ‘std::pointer_to_unary_function<_Arg, _Result> std::ptr_fun(_Result (*)(_Arg)) [with _Arg = int; _Result = int]’ is deprecated: use 'std::function' instead [-Werror=deprecated-declarations]
   55 |         s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
      |                                                              ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/stl_function.h:1126:5: note: declared here
 1126 |     ptr_fun(_Result (*__x)(_Arg))
      |     ^~~~~~~
/home/peter/diverse/programmering/opengl/tmxparser/src/TmxUtil.cpp:55:61: error: ‘constexpr std::unary_negate<_Predicate> std::not1(const _Predicate&) [with _Predicate = pointer_to_unary_function<int, int>]’ is deprecated: use 'std::not_fn' instead [-Werror=deprecated-declarations]
   55 |         s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
      |                                                    ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/stl_function.h:1046:5: note: declared here
 1046 |     not1(const _Predicate& __pred)
      |     ^~~~
cc1plus: all warnings being treated as errors

The ptr_fun has been deprecated in C++11 and removed in C++17. I built the code using the standard CMake settings (cxx_cpp11) but it still seems to fail.

See
https://en.cppreference.com/w/cpp/utility/functional/ptr_fun

And a possible solution here:
https://stackoverflow.com/questions/44973435/stdptr-fun-replacement-for-c17

Fixed in PR #85

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant