CGAL / cgal

The public CGAL repository, see the README below
https://github.com/CGAL/cgal#readme
Other
5k stars 1.39k forks source link

std::equal_to<T>::result_type deprecated in C++17 #3083

Closed afabri closed 3 years ago

afabri commented 6 years ago

Issue Details

See cppreference

Warning in the Kernel_d testsuite

Note that we get the warning also for many other functors of the STL, for example when they are used in Compose classes in <CGAL/function_objects.h>.

We probably should also deprecate them.
@mglisse, @lrineau Do we have to use result_ofor invoke_result instead (cppreference)

Environment

lrineau commented 6 years ago

@afabri commented on May 10, 2018, 12:47 PM GMT+2:

@mglisse, @lrineau Do we have to use result_ofor invoke_result instead (cppreference)

I think our CGAL::cpp11::result_of will have to be implemented in term of std::invoke_result (or boost::result_of) for C++20 and later.

#if CGAL_CXX11
#  include <type_traits>
#else // C++<11
#  include <boost/utility/result_of.hpp>
#endif // end C++<11

namespace CGAL {
  namespace cpp11 {
#if CGAL_CXX20
    template <typename Signature> class result_of;

    template <typename F, typename... Args>
    class result_of<F(Args...)> : public std::invoke_result<F, Args...> {};
#elif CGAL_CXX11
  using std::result_of
#else // C++<11
  using boost::result_of;
#endif // 
  } // end cpp11
} // end CGAL

Then, once drop the support for C++03 and only support C++11 or later, we can switch to the API of std::invoke_result, with variadic templates: we will create a CGAL::cpp20::invoke_result, being a using std::invoke_result (if C++>=20) or a reimplementation using std::result_of.

// now we require C++11 or later
#include <type_traits>

namespace CGAL {
  namespace cpp20 {
#if CGAL_CXX20
    using std::invoke_result;
#else // C++<20
    template <typename F, typename... Args> using invoke_result = result_of<F(Args...)>;
#endif // end C++<20
  } // end cpp20
} // end CGAL

We can even do both during a transition period.