Prepare for Crypto++ 8.2 release

Make ConstBytePtr return non-NULL pointer
pull/828/head CRYPTOPP_8_2_0
Jeffrey Walton 2019-04-28 19:37:23 -04:00
parent ec1aa8874c
commit 9dcc26c582
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
1 changed files with 5 additions and 5 deletions

10
misc.h
View File

@ -390,6 +390,7 @@ inline size_t PtrByteDiff(const PTR pointer1, const PTR pointer2)
/// \brief Pointer to the first element of a string /// \brief Pointer to the first element of a string
/// \param str std::string /// \param str std::string
/// \details BytePtr returns NULL pointer for an empty string.
/// \return Pointer to the first element of a string /// \return Pointer to the first element of a string
inline byte* BytePtr(std::string& str) inline byte* BytePtr(std::string& str)
{ {
@ -401,15 +402,14 @@ inline byte* BytePtr(std::string& str)
return reinterpret_cast<byte*>(&str[0]); return reinterpret_cast<byte*>(&str[0]);
} }
/// \brief Pointer to the first element of a string /// \brief Const pointer to the first element of a string
/// \param str std::string /// \param str std::string
/// \details Use ConstBytePtr if Microsoft compilers match the wrong function. /// \details ConstBytePtr returns non-NULL pointer for an empty string.
/// \return Pointer to the first element of a string /// \return Pointer to the first element of a string
inline const byte* ConstBytePtr(const std::string& str) inline const byte* ConstBytePtr(const std::string& str)
{ {
if (str.empty()) // Use c_str() so a pointer is always available
return NULLPTR; return reinterpret_cast<const byte*>(str.c_str());
return reinterpret_cast<const byte*>(&str[0]);
} }
/// \brief Size of a string /// \brief Size of a string