Skip to content

Update documentation for byterator #223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Some of the extras are available only with C++20 or later.

*stdx* supports:

- clang 14 through 19
- clang 14 through 20
- gcc 12 through 14

See the [full documentation](https://intel.github.io/cpp-std-extensions/).
4 changes: 2 additions & 2 deletions docs/bit.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ integral type that will fit a compile-time value.

[source,cpp]
----
constexpr auto x = stdx::smallest_uint<42>(); // std::uint8_t{}
constexpr auto y = stdx::smallest_uint<1337>(); // std::uint16_t{}
constexpr auto x = stdx::smallest_uint<42>(); // std::uint8_t{42}
constexpr auto y = stdx::smallest_uint<1337>(); // std::uint16_t{1337}

// smallest_uint_t is the type of a call to smallest_uint
using T = stdx::smallest_uint_t<1337>; // std::uint16_t
Expand Down
4 changes: 4 additions & 0 deletions docs/byterator.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ i.writeu16(v16); // write and advance
auto v32 = i.peeku32(); // read value without advancing
v32 = i.readu32(); // read and advance
i.writeu32(v32); // write and advance

auto v64 = i.peeku64(); // read value without advancing
v64 = i.readu64(); // read and advance
i.writeu64(v64); // write and advance
----

These convenience functions are implemented by function templates that offer
Expand Down
3 changes: 3 additions & 0 deletions docs/intro.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ The following compilers are supported:
* clang 16
* clang 17
* clang 18
* clang 19
* clang 20
* gcc 12
* gcc 13
* gcc 14

In general, `stdx` supports the C++17 standard; however some functionality is
available only in 20 and later.
Expand Down
8 changes: 4 additions & 4 deletions include/stdx/bit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,13 @@ template <typename T> constexpr auto bit_size() -> std::size_t {

template <std::size_t N> CONSTEVAL auto smallest_uint() {
if constexpr (N <= std::numeric_limits<std::uint8_t>::digits) {
return std::uint8_t{};
return std::uint8_t{N};
} else if constexpr (N <= std::numeric_limits<std::uint16_t>::digits) {
return std::uint16_t{};
return std::uint16_t{N};
} else if constexpr (N <= std::numeric_limits<std::uint32_t>::digits) {
return std::uint32_t{};
return std::uint32_t{N};
} else {
return std::uint64_t{};
return std::uint64_t{N};
}
}

Expand Down