Skip to content

Remove binary_function from ginac's code in sage #34573

@kiwifb

Description

@kiwifb

The use of std::binary_function and std::unary_function have been deprecated for almost 10 years and gcc-12 is now signalling it. They may be completely removed soon. We get the following warnings when building sage

INFO: compile options: '-I./sage/cpython -I/home/portage/sci-mathematics/sage-9999/work/sage-9999/src -I/usr/lib/python3.10/site-packages/numpy/core/include -I/usr/include/python3.10 -Ibuild/cythonized -I/usr/include/python3.10 -c'
extra options: '-fno-strict-aliasing -DCYTHON_CLINE_IN_TRACEBACK=1'
INFO: x86_64-pc-linux-gnu-gcc: build/cythonized/sage/symbolic/ring.c
INFO: x86_64-pc-linux-gnu-gcc: sage/symbolic/ginac/ex.cpp
In file included from sage/symbolic/ginac/basic.h:35,
                 from sage/symbolic/ginac/ex.h:26,
                 from sage/symbolic/ginac/assume.cpp:8:
sage/symbolic/ginac/ptr.h:162:11: warning: ‘template<class _Arg1, class _Arg2, class _Result> struct std::binary_function’ is deprecated [-Wdeprecated-declarations]
  162 |  : public binary_function<GiNaC::ptr<T>, GiNaC::ptr<T>, bool> {
      |           ^~~~~~~~~~~~~~~
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/g++-v12/bits/refwrap.h:39,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/g++-v12/vector:66,
                 from sage/symbolic/ginac/basic.h:26:
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/g++-v12/bits/stl_function.h:131:12: note: declared here

The following files contain offending code

src/sage/symbolic/ginac/order.h:class print_order : public std::binary_function<ex, ex, bool> {
src/sage/symbolic/ginac/order.h:        public std::binary_function<expair, expair, bool>
src/sage/symbolic/ginac/expair.h:struct expair_is_less : public std::binary_function<expair, expair, bool> {
src/sage/symbolic/ginac/expair.h:struct expair_rest_is_less : public std::binary_function<expair, expair, bool> {
src/sage/symbolic/ginac/expair.h:struct expair_swap : public std::binary_function<expair, expair, void> {
src/sage/symbolic/ginac/ptr.h: : public binary_function<GiNaC::ptr<T>, GiNaC::ptr<T>, bool> {
src/sage/symbolic/ginac/ex.h:struct ex_is_less : public std::binary_function<ex, ex, bool> {
src/sage/symbolic/ginac/ex.h:struct ex_is_equal : public std::binary_function<ex, ex, bool> {
src/sage/symbolic/ginac/ex.h:struct op0_is_equal : public std::binary_function<ex, ex, bool> {
src/sage/symbolic/ginac/ex.h:struct ex_swap : public std::binary_function<ex, ex, void> {

There are no instances of unary_function in sage.

I did a similar clean up in brial quite recently https://github.com/BRiAl/BRiAl/pull/52/files

CC: @antonio-rojas

Component: porting

Author: François Bissey

Branch/Commit: 0dc211b

Reviewer: Matthias Koeppe

Issue created by migration from https://trac.sagemath.org/ticket/34573

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions