From a399339a9731ed254e094aa7d88a1ef17c824c6f Mon Sep 17 00:00:00 2001
From: Timo Koch <timo.koch@iws.uni-stuttgart.de>
Date: Mon, 30 Mar 2020 11:23:01 +0200
Subject: [PATCH] [rootfinding] Use C++17 invocable_r. Additionally checks
 return type is convertible

---
 dumux/nonlinear/findscalarroot.hh | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/dumux/nonlinear/findscalarroot.hh b/dumux/nonlinear/findscalarroot.hh
index 7c230d47fe..9eff421612 100644
--- a/dumux/nonlinear/findscalarroot.hh
+++ b/dumux/nonlinear/findscalarroot.hh
@@ -26,8 +26,7 @@
 
 #include <cmath>
 #include <limits>
-
-#include <dune/common/std/type_traits.hh>
+#include <type_traits>
 
 #include <dumux/common/exceptions.hh>
 #include <dumux/common/parameters.hh>
@@ -43,11 +42,10 @@ namespace Dumux {
  * \param derivative Derivative of the residual
  * \param tol Relative shift tolerance
  * \param maxIter Maximum number of iterations
- * \todo replace std::result_of by std::invoke_result for C++17
  */
 template<class Scalar, class ResFunc, class DerivFunc,
-         typename std::enable_if_t<Dune::Std::is_invocable<ResFunc, Scalar>::value &&
-                                   Dune::Std::is_invocable<DerivFunc, Scalar>::value>...>
+         typename std::enable_if_t<std::is_invocable_r_v<Scalar, ResFunc, Scalar> &&
+                                   std::is_invocable_r_v<Scalar, DerivFunc, Scalar>>...>
 Scalar findScalarRootNewton(Scalar xOld, const ResFunc& residual, const DerivFunc& derivative,
                             const Scalar tol = 1e-13, const int maxIter = 200)
 {
@@ -87,7 +85,7 @@ Scalar findScalarRootNewton(Scalar xOld, const ResFunc& residual, const DerivFun
  * \param maxIter Maximum number of iterations
  */
 template<class Scalar, class ResFunc,
-          typename std::enable_if_t<Dune::Std::is_invocable<ResFunc, Scalar>::value>...>
+          typename std::enable_if_t<std::is_invocable_r_v<Scalar, ResFunc, Scalar>>...>
 Scalar findScalarRootNewton(Scalar xOld, const ResFunc& residual,
                             const Scalar tol = 1e-13, const int maxIter = 200)
 {
@@ -109,7 +107,7 @@ Scalar findScalarRootNewton(Scalar xOld, const ResFunc& residual,
  * \param maxIter Maximum number of iterations
  */
 template<class Scalar, class ResFunc,
-         typename std::enable_if_t<Dune::Std::is_invocable<ResFunc, Scalar>::value>...>
+         typename std::enable_if_t<std::is_invocable_r_v<Scalar, ResFunc, Scalar>>...>
 Scalar findScalarRootBrent(Scalar a, Scalar b, const ResFunc& residual,
                            const Scalar tol = 1e-13, const int maxIter = 200)
 {
-- 
GitLab