Add to_char_type function to custom char_traits

This commit is contained in:
Colby Haskell 2023-11-13 13:27:14 -05:00
parent 6c83919adb
commit 543158bbf3
2 changed files with 28 additions and 8 deletions

View File

@ -199,12 +199,17 @@ struct char_traits<unsigned char> : std::char_traits<char>
using int_type = uint64_t;
// Redefine to_int_type function
static int_type to_int_type(char_type c)
static int_type to_int_type(char_type c) noexcept
{
return static_cast<int_type>(c);
}
static constexpr int_type eof()
static char_type to_char_type(int_type i) noexcept
{
return static_cast<char_type>(i);
}
static constexpr int_type eof() noexcept
{
return static_cast<int_type>(EOF);
}
@ -218,12 +223,17 @@ struct char_traits<signed char> : std::char_traits<char>
using int_type = uint64_t;
// Redefine to_int_type function
static int_type to_int_type(char_type c)
static int_type to_int_type(char_type c) noexcept
{
return static_cast<int_type>(c);
}
static constexpr int_type eof()
static char_type to_char_type(int_type i) noexcept
{
return static_cast<char_type>(i);
}
static constexpr int_type eof() noexcept
{
return static_cast<int_type>(EOF);
}

View File

@ -3612,12 +3612,17 @@ struct char_traits<unsigned char> : std::char_traits<char>
using int_type = uint64_t;
// Redefine to_int_type function
static int_type to_int_type(char_type c)
static int_type to_int_type(char_type c) noexcept
{
return static_cast<int_type>(c);
}
static constexpr int_type eof()
static char_type to_char_type(int_type i) noexcept
{
return static_cast<char_type>(i);
}
static constexpr int_type eof() noexcept
{
return static_cast<int_type>(EOF);
}
@ -3631,12 +3636,17 @@ struct char_traits<signed char> : std::char_traits<char>
using int_type = uint64_t;
// Redefine to_int_type function
static int_type to_int_type(char_type c)
static int_type to_int_type(char_type c) noexcept
{
return static_cast<int_type>(c);
}
static constexpr int_type eof()
static char_type to_char_type(int_type i) noexcept
{
return static_cast<char_type>(i);
}
static constexpr int_type eof() noexcept
{
return static_cast<int_type>(EOF);
}