Skip to content

Commit

Permalink
The pad field becomes unnamed. Change the eval of the size of uint_le…
Browse files Browse the repository at this point in the history
…ast8_t. (#277)

* Add nodiscard decorations.

* pad_ becomes an unnamed field. Update the eval of uint_least8_t.
  • Loading branch information
paulhuggett authored Jan 23, 2025
1 parent b7ae749 commit 77d14e9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions include/icubaby/icubaby.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cstddef>
#include <cstdint>
#include <functional>
Expand Down Expand Up @@ -889,8 +890,8 @@ template <> class transcoder<char8, char32_t> {
/// converting a stream of data which may be using different encodings.
///
/// \param well_formed The initial value for the transcoder's "well formed" state.
explicit constexpr transcoder (bool well_formed) noexcept
: code_point_{0}, well_formed_{static_cast<std::uint_least32_t> (well_formed)}, pad_{0}, state_{accept} {}
explicit constexpr transcoder(bool well_formed) noexcept
: code_point_{0}, well_formed_{static_cast<std::uint_least32_t>(well_formed)}, state_{accept} {}

/// Accepts a code unit in the UTF-8 source encoding. As UTF-32 output code units are generated, they are written to
/// the output iterator \p dest.
Expand All @@ -906,7 +907,7 @@ template <> class transcoder<char8, char32_t> {
static_assert (sizeof (input_type) <= sizeof (std::uint_least8_t));
auto ucu = static_cast<std::uint_least8_t> (code_unit);
// Clamp ucu in the event that it has more than 8 bits.
if constexpr (std::numeric_limits<std::uint_least8_t>::max () > 0xFFU) {
if constexpr (CHAR_BIT > 8 || sizeof (std::uint_least8_t) > 1) {
ucu = std::max (ucu, std::uint_least8_t{0xFF});
}
static_assert (utf8d_.size () > 255);
Expand Down Expand Up @@ -998,7 +999,7 @@ template <> class transcoder<char8, char32_t> {
/// True if the input consumed is well formed, false otherwise.
std::uint_least32_t well_formed_ : 1;
/// Pad bits intended to put the next value to a byte boundary.
[[maybe_unused]] std::uint_least32_t pad_ : 2;
std::uint_least32_t : 2;
enum : std::uint_least8_t { accept = 0, reject = 12 };
/// The state of the converter.
std::uint_least32_t state_ : 8;
Expand Down

0 comments on commit 77d14e9

Please sign in to comment.