diff options
author | Jeffrey Walton <noloader@gmail.com> | 2021-03-09 22:51:19 -0500 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2021-03-09 22:51:19 -0500 |
commit | f7e6af6344f2b1f3e4a6afe1ac2cc870af2d3944 (patch) | |
tree | 49c9d4a6760efec8114df7366a007befd08c5b5a /misc.h | |
parent | 5c4c631e9291c57e237d6d40bb2c3456eb597f3d (diff) | |
download | cryptopp-git-f7e6af6344f2b1f3e4a6afe1ac2cc870af2d3944.tar.gz |
Add EnumToInt conversion macro for enum-enum conversion warnings (GH #1016)
Diffstat (limited to 'misc.h')
-rw-r--r-- | misc.h | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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()
|