Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dumux-repositories
dumux
Commits
a399339a
Commit
a399339a
authored
Mar 30, 2020
by
Timo Koch
Browse files
[rootfinding] Use C++17 invocable_r. Additionally checks return type is convertible
parent
fbedc32e
Changes
1
Hide whitespace changes
Inline
Side-by-side
dumux/nonlinear/findscalarroot.hh
View file @
a399339a
...
...
@@ -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
::
S
td
::
is_invocable
<
ResFunc
,
Scalar
>
::
value
&&
Dune
::
S
td
::
is_invocable
<
DerivFunc
,
Scalar
>
::
value
>
...
>
typename
std
::
enable_if_t
<
s
td
::
is_invocable
_r_v
<
Scalar
,
ResFunc
,
Scalar
>
&&
s
td
::
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
::
S
td
::
is_invocable
<
ResFunc
,
Scalar
>
::
value
>
...
>
typename
std
::
enable_if_t
<
s
td
::
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
::
S
td
::
is_invocable
<
ResFunc
,
Scalar
>
::
value
>
...
>
typename
std
::
enable_if_t
<
s
td
::
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
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment