1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

cleanup: make Name and STRING_WITH_LEN usable in constexpr

This commit is contained in:
Sergei Golubchik
2023-07-05 14:43:46 +02:00
parent 15a42a0a18
commit f3bacd708a
2 changed files with 7 additions and 12 deletions

View File

@ -201,7 +201,7 @@ extern ulonglong strtoull(const char *str, char **ptr, int base);
#ifdef __cplusplus #ifdef __cplusplus
#include <type_traits> #include <type_traits>
template<typename T> inline const char *_swl_check(T s) template<typename T> inline constexpr const char *_swl_check(T s)
{ {
static_assert(std::is_same<T, const char (&)[sizeof(T)]>::value static_assert(std::is_same<T, const char (&)[sizeof(T)]>::value
|| std::is_same<T, const char [sizeof(T)]>::value, || std::is_same<T, const char [sizeof(T)]>::value,

View File

@ -3384,17 +3384,12 @@ public:
class Name: private LEX_CSTRING class Name: private LEX_CSTRING
{ {
public: public:
Name(const char *str_arg, uint length_arg) constexpr Name(const char *str_arg, uint length_arg) :
{ LEX_CSTRING({str_arg, length_arg})
DBUG_ASSERT(length_arg < UINT_MAX32); { }
LEX_CSTRING::str= str_arg; constexpr Name(const LEX_CSTRING &lcs) :
LEX_CSTRING::length= length_arg; LEX_CSTRING(lcs)
} { }
Name(const LEX_CSTRING &lcs)
{
LEX_CSTRING::str= lcs.str;
LEX_CSTRING::length= lcs.length;
}
const char *ptr() const { return LEX_CSTRING::str; } const char *ptr() const { return LEX_CSTRING::str; }
uint length() const { return (uint) LEX_CSTRING::length; } uint length() const { return (uint) LEX_CSTRING::length; }
const LEX_CSTRING &lex_cstring() const { return *this; } const LEX_CSTRING &lex_cstring() const { return *this; }