summaryrefslogtreecommitdiff
path: root/misc.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2021-03-09 22:51:19 -0500
committerJeffrey Walton <noloader@gmail.com>2021-03-09 22:51:19 -0500
commitf7e6af6344f2b1f3e4a6afe1ac2cc870af2d3944 (patch)
tree49c9d4a6760efec8114df7366a007befd08c5b5a /misc.h
parent5c4c631e9291c57e237d6d40bb2c3456eb597f3d (diff)
downloadcryptopp-git-f7e6af6344f2b1f3e4a6afe1ac2cc870af2d3944.tar.gz
Add EnumToInt conversion macro for enum-enum conversion warnings (GH #1016)
Diffstat (limited to 'misc.h')
-rw-r--r--misc.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/misc.h b/misc.h
index 5f9e6eed..b2272ae9 100644
--- a/misc.h
+++ b/misc.h
@@ -473,6 +473,7 @@ const byte* ConstBytePtr(const SecByteBlock& str);
/// \brief Size of a string
/// \param str std::string
/// \return size of a string
+/// \since Crypto++ 8.3
inline size_t BytePtrSize(const std::string& str)
{
return str.size();
@@ -481,8 +482,18 @@ inline size_t BytePtrSize(const std::string& str)
/// \brief Size of a string
/// \param str SecByteBlock
/// \return size of a string
+/// \since Crypto++ 8.3
size_t BytePtrSize(const SecByteBlock& str);
+/// \brief Integer value
+/// \details EnumToInt is a convenience macro to convert enums
+/// to integers. The cast avoids C++20 enum-enum conversion
+/// warnings.
+/// \details A macro is used due to [lack of] constexpr-ness in
+/// early versions of C++.
+/// \since Crypto++ 8.6
+#define EnumToInt(v) static_cast<int>(v)
+
#if (!__STDC_WANT_SECURE_LIB__ && !defined(_MEMORY_S_DEFINED)) || defined(CRYPTOPP_WANT_SECURE_LIB)
/// \brief Bounds checking replacement for memcpy()