Skip to content

Commit

Permalink
cleanup: make Name and STRING_WITH_LEN usable in constexpr
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed Jul 5, 2023
1 parent 15a42a0 commit f3bacd7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion include/m_string.h
Expand Up @@ -201,7 +201,7 @@ extern ulonglong strtoull(const char *str, char **ptr, int base);

#ifdef __cplusplus
#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
|| std::is_same<T, const char [sizeof(T)]>::value,
Expand Down
17 changes: 6 additions & 11 deletions sql/sql_type.h
Expand Up @@ -3384,17 +3384,12 @@ class Type_cast_attributes
class Name: private LEX_CSTRING
{
public:
Name(const char *str_arg, uint length_arg)
{
DBUG_ASSERT(length_arg < UINT_MAX32);
LEX_CSTRING::str= str_arg;
LEX_CSTRING::length= length_arg;
}
Name(const LEX_CSTRING &lcs)
{
LEX_CSTRING::str= lcs.str;
LEX_CSTRING::length= lcs.length;
}
constexpr Name(const char *str_arg, uint length_arg) :
LEX_CSTRING({str_arg, length_arg})
{ }
constexpr Name(const LEX_CSTRING &lcs) :
LEX_CSTRING(lcs)
{ }
const char *ptr() const { return LEX_CSTRING::str; }
uint length() const { return (uint) LEX_CSTRING::length; }
const LEX_CSTRING &lex_cstring() const { return *this; }
Expand Down

0 comments on commit f3bacd7

Please sign in to comment.