[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 97416cf 7/9: Emulate C++23 to_underlying<>()
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 97416cf 7/9: Emulate C++23 to_underlying<>() |
Date: |
Sat, 23 Oct 2021 18:32:44 -0400 (EDT) |
branch: master
commit 97416cf55eda997ce06593159a5ed2a763bab955
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Emulate C++23 to_underlying<>()
---
test_coding_rules.cpp | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/test_coding_rules.cpp b/test_coding_rules.cpp
index d50ea97..3562ba8 100644
--- a/test_coding_rules.cpp
+++ b/test_coding_rules.cpp
@@ -255,6 +255,14 @@ bool file::is_of_phylum(enum_phylum z) const
return z & phylum();
}
+/// Helper, to be deprecated for C++23.
+
+template<typename E>
+constexpr std::underlying_type_t<E> to_underlying(E e) noexcept
+{
+ return static_cast<std::underlying_type_t<E>>(e);
+}
+
/// Ascertain whether a file appertains to the given category.
///
/// This relation may be read as "has the X-nature". For example,
@@ -266,7 +274,7 @@ bool file::is_of_phylum(enum_kingdom z) const
// though this is safe here because enum_kingdom only contains combinations
// of primitive phyla from enum_phylum, so cast to the underlying type to
// avoid warnings/errors about this generally unsafe operation.
- return static_cast<std::underlying_type_t<enum_kingdom>>(z) & phylum();
+ return to_underlying(z) & phylum();
}
/// Analyze a file's name to determine its phylum.
- [lmi-commits] [lmi] master updated (03dc638 -> b0c70e0), Greg Chicares, 2021/10/23
- [lmi-commits] [lmi] master bbc5038 2/9: Disable gcc -Wdeprecated-enum-float-conversion, Greg Chicares, 2021/10/23
- [lmi-commits] [lmi] master a5db27e 1/9: Recognize gcc and g++ 11 versions in the makefile, Greg Chicares, 2021/10/23
- [lmi-commits] [lmi] master d810372 3/9: Trade elegance for simplicity, Greg Chicares, 2021/10/23
- [lmi-commits] [lmi] master 33de332 5/9: Prefer 'long int' to 'long', Greg Chicares, 2021/10/23
- [lmi-commits] [lmi] master e908d9e 8/9: Don't disable -Wdeprecated-enum-enum-conversion in configure, Greg Chicares, 2021/10/23
- [lmi-commits] [lmi] master 1cefad6 4/9: Fix LMI_WX_CHILD_DOCUMENT definition to fix g++11 C++20 build, Greg Chicares, 2021/10/23
- [lmi-commits] [lmi] master a5de0ea 6/9: Fix gcc11 -Wdeprecated-enum-enum-conversion in test_coding_rules, Greg Chicares, 2021/10/23
- [lmi-commits] [lmi] master 97416cf 7/9: Emulate C++23 to_underlying<>(),
Greg Chicares <=
- [lmi-commits] [lmi] master b0c70e0 9/9: Update wxWidgets submodule to fix gcc11 -Wshadow warnings, Greg Chicares, 2021/10/23