Include review feedback

parent 86cdab59
......@@ -64,7 +64,7 @@ public:
return static_cast<size_t>(end_ - current_);
}
/// Returns the remaining std::bytes.
/// Returns the remaining bytes.
span<const std::byte> remainder() const noexcept {
return make_span(current_, end_);
}
......@@ -203,7 +203,7 @@ public:
private:
explicit binary_deserializer(actor_system& sys) noexcept;
/// Checks whether we can read `read_size` more std::bytes.
/// Checks whether we can read `read_size` more bytes.
bool range_check(size_t read_size) const noexcept {
return current_ + read_size <= end_;
}
......
// Deprecated include. The next CAF release won't include this header.
#include <cstddef>
#include <type_traits>
#pragma once
namespace caf {
template <class IntegerType,
class = std::enable_if_t<std::is_integral<IntegerType>::value>>
constexpr IntegerType to_integer(std::byte x) noexcept {
return static_cast<IntegerType>(x);
}
} // namespace caf
......@@ -184,8 +184,8 @@ public:
/// @copydoc value
virtual bool value(std::u32string&) = 0;
/// Reads a std::byte sequence from the input.
/// @param x The std::byte sequence.
/// Reads a byte sequence from the input.
/// @param x The byte sequence.
/// @returns A non-zero error code on failure, `sec::success` otherwise.
virtual bool value(span<std::byte> x) = 0;
......@@ -193,7 +193,7 @@ public:
/// Adds each boolean in `xs` to the output. Derived classes can override this
/// member function to pack the booleans, for example to avoid using one
/// std::byte for each value in a binary output format.
/// byte for each value in a binary output format.
virtual bool list(std::vector<bool>& xs);
protected:
......
......@@ -21,13 +21,13 @@ public:
/// Uses placement new to create a copy of the wrapped value at given memory
/// region.
/// @returns the past-the-end pointer of the object, i.e., the first std::byte
/// @returns the past-the-end pointer of the object, i.e., the first byte
/// for
/// the *next* object.
virtual std::byte* copy_init(std::byte* storage) const = 0;
/// Uses placement new to move the wrapped value to given memory region.
/// @returns the past-the-end pointer of the object, i.e., the first std::byte
/// @returns the past-the-end pointer of the object, i.e., the first byte
/// for
/// the *next* object.
virtual std::byte* move_init(std::byte* storage) = 0;
......
......@@ -156,8 +156,8 @@ public:
/// @copydoc value
virtual bool value(const std::u32string& x) = 0;
/// Adds `x` as raw std::byte block to the output.
/// @param x The std::byte sequence.
/// Adds `x` as raw byte block to the output.
/// @param x The byte sequence.
/// @returns A non-zero error code on failure, `sec::success` otherwise.
virtual bool value(span<const std::byte> x) = 0;
......@@ -165,7 +165,7 @@ public:
/// Adds each boolean in `xs` to the output. Derived classes can override this
/// member function to pack the booleans, for example to avoid using one
/// std::byte for each value in a binary output format.
/// byte for each value in a binary output format.
virtual bool list(const std::vector<bool>& xs);
protected:
......
......@@ -603,7 +603,7 @@ bool json_reader::value(std::u32string&) {
bool json_reader::value(span<std::byte>) {
emplace_error(sec::runtime_error, class_name, __func__,
"std::byte span support not implemented yet");
"byte span support not implemented yet");
return false;
}
......
......@@ -289,7 +289,7 @@ bool json_writer::end_associative_array() {
}
bool json_writer::value(std::byte x) {
return number(static_cast<uint8_t>(x));
return number(std::to_integer<uint8_t>(x));
}
bool json_writer::value(bool x) {
......
......@@ -67,11 +67,11 @@ uuid::variant_field variant_table[] = {
} // namespace
uuid::variant_field uuid::variant() const noexcept {
return variant_table[static_cast<size_t>(bytes_[8]) >> 5];
return variant_table[std::to_integer<size_t>(bytes_[8]) >> 5];
}
uuid::version_field uuid::version() const noexcept {
return static_cast<version_field>(static_cast<int>(bytes_[6]) >> 4);
return static_cast<version_field>(std::to_integer<int>(bytes_[6]) >> 4);
}
uint64_t uuid::timestamp() const noexcept {
......@@ -84,7 +84,7 @@ uint64_t uuid::timestamp() const noexcept {
ts[0] &= std::byte{0x0F};
uint64_t result;
memcpy(&result, ts, 8);
// UUIDs are stored in network std::byte order.
// UUIDs are stored in network byte order.
return detail::from_network_order(result);
}
......@@ -95,7 +95,7 @@ uint16_t uuid::clock_sequence() const noexcept {
cs[0] &= std::byte{0x3F};
uint16_t result;
memcpy(&result, cs, 2);
// UUIDs are stored in network std::byte order.
// UUIDs are stored in network byte order.
return detail::from_network_order(result);
}
......@@ -153,7 +153,8 @@ parse_result parse_impl(string_parser_state& ps, uuid::array_type& x) noexcept {
// Check whether the bytes form a valid UUID.
if (memcmp(x.data(), nil_bytes, 16) == 0)
return valid_uuid;
if (auto subtype = static_cast<long>(x[6]) >> 4; subtype == 0 || subtype > 5)
if (auto subtype = std::to_integer<long>(x[6]) >> 4;
subtype == 0 || subtype > 5)
return invalid_version;
return valid_uuid;
}
......
......@@ -59,7 +59,7 @@ CAF_TEST_FIXTURE_SCOPE(uuid_tests, fixture)
CAF_TEST(default generated UUIDs have all 128 bits set to zero) {
uuid nil;
CAF_CHECK(!nil);
auto zero = [](std::byte x) { return static_cast<int>(x) == 0; };
auto zero = [](std::byte x) { return std::to_integer<int>(x) == 0; };
CAF_CHECK(std::all_of(nil.bytes().begin(), nil.bytes().end(), zero));
CAF_CHECK(nil == uuid::nil());
}
......
......@@ -38,7 +38,7 @@ class middleman;
///
/// Brokers do *not* operate on sockets or other platform-dependent
/// communication primitives. Instead, brokers use a `connection_handle`
/// to identify a reliable, end-to-end std::byte stream (e.g. a TCP connection)
/// to identify a reliable, end-to-end byte stream (e.g. a TCP connection)
/// and `accept_handle` to identify a communication endpoint others can
/// connect to via its port.
///
......
......@@ -889,7 +889,7 @@ bool test_multiplexer::read_data(datagram_handle hdl) {
CAF_ASSERT(to.second.capacity() > from.second.size());
to.second.resize(from.second.size());
std::transform(from.second.begin(), from.second.end(), to.second.begin(),
[](std::byte x) { return static_cast<char>(x); });
[](std::byte x) { return std::to_integer<char>(x); });
data->vn_buf.pop_front();
auto sitr = datagram_data_.find(data->rd_buf.first);
if (sitr == datagram_data_.end()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment