summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/plib/pgsl.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/netlist/plib/pgsl.h')
-rw-r--r--src/lib/netlist/plib/pgsl.h22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/lib/netlist/plib/pgsl.h b/src/lib/netlist/plib/pgsl.h
index 1ea8622d19c..4ddc957b9ac 100644
--- a/src/lib/netlist/plib/pgsl.h
+++ b/src/lib/netlist/plib/pgsl.h
@@ -36,10 +36,24 @@
#define gsl_Expects(e) ((e) ? static_cast<void>(0) : static_cast<void>(0))
#endif
-#if 0
+#if 1
+// FIXME: __builtin_unreachable contrary to google sources does not seem to be of
+// any use and decreases performance slightly. Convert gsl_Expects to a noop
+// and revisit in the future.
#undef gsl_Expects
#define gsl_Expects(e) do {} while (0)
+
+#if 0
+// Alternative and c++ style implementation. Suffers from the same drawbacks
+// like __builtin_unreachable
+static constexpr inline void gsl_Expects(const bool &e)
+{
+ if (!e)
+ __builtin_unreachable();
+}
#endif
+#endif
+
#define gsl_Ensures(e) gsl_Expects(e)
namespace plib {
@@ -56,7 +70,7 @@ namespace plib {
/// \brief perform a narrowing cast without checks
///
template <typename T, typename O>
- inline constexpr T narrow_cast(O && v) noexcept
+ constexpr T narrow_cast(O && v) noexcept
{
static_assert(plib::is_arithmetic<T>::value && std::is_convertible<std::remove_reference_t<O>, T>::value, "narrow cast expects conversion between arithmetic types");
return static_cast<T>(std::forward<O>(v));
@@ -66,7 +80,7 @@ namespace plib {
///
/// The c++ core guidelines require the narrow function to raise an error
/// This will make narrow noexcept(false). This has shown to have a
- /// measurable impact on performance and thus we deviate we deviate from
+ /// measurable impact on performance and thus we deviate from
/// the standard here.
///
template <typename T, typename O>
@@ -86,7 +100,7 @@ namespace plib {
} // namespace pgsl
- /// \brief downcast from base tpye to derived type
+ /// \brief downcast from base type to derived type
///
/// The cpp core guidelines require a very careful use of static cast
/// for downcast operations. This template is used to identify these uses