[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 4d8cb22 1/3: Work around a clang issue
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 4d8cb22 1/3: Work around a clang issue |
Date: |
Tue, 13 Jul 2021 22:10:48 -0400 (EDT) |
branch: master
commit 4d8cb229289c8a55d1037935d600300fca0227f9
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Work around a clang issue
Revert this commit when clang supports std::identity.
---
zero.hpp | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/zero.hpp b/zero.hpp
index da1ae65..a860644 100644
--- a/zero.hpp
+++ b/zero.hpp
@@ -33,6 +33,7 @@
#include <iomanip> // setw()
#include <limits>
#include <ostream>
+#include <utility> // forward()
enum root_bias
{bias_none // Return root z with f(z) closest to 0.0 .
@@ -66,6 +67,19 @@ namespace detail
using RoundT = std::function<double(double)>;
} // namespace detail
+/// Workaround for clang--see:
+/// https://lists.nongnu.org/archive/html/lmi/2021-07/msg00001.html
+/// It is hoped that this can be replaced by std::identity soon.
+
+struct lmi_identity
+{
+ using is_transparent = void;
+
+ template<typename T>
+ constexpr T&& operator()(T&& t) const noexcept
+ {return std::forward<T>(t);}
+};
+
/// Return a zero z of a function f within input bounds [a,b].
///
/// Preconditions: bounds are distinct after rounding; and either
@@ -242,7 +256,8 @@ root_type lmi_root
,double tolerance
,std::ostream& os_trace = null_stream()
,root_bias bias = bias_none
- ,detail::RoundT round_dec = std::identity()
+// ,detail::RoundT round_dec = std::identity()
+ ,detail::RoundT round_dec = lmi_identity()
)
{
constexpr double epsilon {std::numeric_limits<double>::epsilon()};