Skip to content

Commit

Permalink
fix build with llvm-18 by changing Bytestring type to std::vector ins…
Browse files Browse the repository at this point in the history
…tead of deprecated std::basic_string<std::byte>
  • Loading branch information
Altren committed Feb 28, 2025
1 parent e6a2623 commit e3cb110
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions include/rfl/Bytestring.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#define RFL_BYTESTRING_HPP_

#include <cstddef>
#include <string>
#include <vector>

namespace rfl {

using Bytestring = std::basic_string<std::byte>;
using Bytestring = std::vector<std::byte>;

} // namespace rfl

Expand Down
3 changes: 2 additions & 1 deletion include/rfl/avro/Reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ struct Reader {
if (err) {
return error("Could not cast to bytestring.");
}
return rfl::Bytestring(static_cast<const std::byte*>(ptr), size - 1);
const auto data = internal::ptr_cast<const std::byte*>(ptr);
return rfl::Bytestring(data, data + size - 1);
} else if constexpr (std::is_same<std::remove_cvref_t<T>, bool>()) {
if (type != AVRO_BOOLEAN) {
return rfl::error("Could not cast to boolean.");
Expand Down
5 changes: 2 additions & 3 deletions include/rfl/bson/Reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,8 @@ struct Reader {
"The BSON subtype must be a binary in order to read into a "
"bytestring.");
}
return rfl::Bytestring(
internal::ptr_cast<const std::byte*>(value.v_binary.data),
value.v_binary.data_len);
const auto data = internal::ptr_cast<const std::byte*>(value.v_binary.data)

Check failure on line 123 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (llvm-16)

expected ';' at end of declaration

Check failure on line 123 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (llvm-16)

expected ';' at end of declaration

Check failure on line 123 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (llvm-16)

expected ';' at end of declaration

Check failure on line 123 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (llvm-16)

expected ';' at end of declaration

Check failure on line 123 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (llvm-18)

expected ';' at end of declaration

Check failure on line 123 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (llvm-18)

expected ';' at end of declaration

Check failure on line 123 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (llvm-18)

expected ';' at end of declaration

Check failure on line 123 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (llvm-18)

expected ';' at end of declaration

Check failure on line 123 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / macos-clang (macos-latest)

expected ';' at end of declaration

Check failure on line 123 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / macos-clang (macos-latest)

expected ';' at end of declaration

Check failure on line 123 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / macos-clang (macos-latest)

expected ';' at end of declaration

Check failure on line 123 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / macos-clang (macos-13)

expected ';' at end of declaration
return rfl::Bytestring(data, data + value.v_binary.data_len);

Check failure on line 124 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (gcc-13)

expected ‘,’ or ‘;’ before ‘return’

Check failure on line 124 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (gcc-13)

expected ‘,’ or ‘;’ before ‘return’

Check failure on line 124 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (gcc-13)

expected ‘,’ or ‘;’ before ‘return’

Check failure on line 124 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (gcc-11)

expected ‘,’ or ‘;’ before ‘return’

Check failure on line 124 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (gcc-11)

expected ‘,’ or ‘;’ before ‘return’

Check failure on line 124 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (gcc-11)

expected ‘,’ or ‘;’ before ‘return’

Check failure on line 124 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (gcc-14)

expected ‘,’ or ‘;’ before ‘return’

Check failure on line 124 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (gcc-14)

expected ‘,’ or ‘;’ before ‘return’

Check failure on line 124 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (gcc-14)

expected ‘,’ or ‘;’ before ‘return’

Check failure on line 124 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (gcc-14)

expected ‘,’ or ‘;’ before ‘return’

Check failure on line 124 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (gcc-12)

expected ‘,’ or ‘;’ before ‘return’

Check failure on line 124 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (gcc-12)

expected ‘,’ or ‘;’ before ‘return’

Check failure on line 124 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (gcc-12)

expected ‘,’ or ‘;’ before ‘return’

Check failure on line 124 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (gcc-14)

expected ‘,’ or ‘;’ before ‘return’

Check failure on line 124 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (gcc-14)

expected ‘,’ or ‘;’ before ‘return’

Check failure on line 124 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (gcc-14)

expected ‘,’ or ‘;’ before ‘return’

Check failure on line 124 in include/rfl/bson/Reader.hpp

View workflow job for this annotation

GitHub Actions / (gcc-14)

expected ‘,’ or ‘;’ before ‘return’
} else if constexpr (std::is_same<std::remove_cvref_t<T>, bool>()) {
if (btype != BSON_TYPE_BOOL) {
return error("Could not cast to boolean.");
Expand Down
4 changes: 2 additions & 2 deletions include/rfl/capnproto/Reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class Reader {
return error("Could not cast to bytestring.");
}
const auto data = _var.val_.as<capnp::Data>();
return rfl::Bytestring(internal::ptr_cast<const std::byte*>(data.begin()),
data.size());
const auto begin = internal::ptr_cast<const std::byte*>(data.begin());
return rfl::Bytestring(begin, begin + data.size());

} else if constexpr (std::is_same<std::remove_cvref_t<T>, bool>()) {
if (type != capnp::DynamicValue::BOOL) {
Expand Down
4 changes: 2 additions & 2 deletions include/rfl/cbor/Reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ class Reader {
return error("Could not cast to bytestring.");
}
const auto vec = _var.val_->as<std::vector<uint8_t>>();
return rfl::Bytestring(internal::ptr_cast<const std::byte*>(vec.data()),
vec.size());
const auto data = internal::ptr_cast<const std::byte*>(vec.data());
return rfl::Bytestring(data, data + vec.size());
} else if constexpr (std::is_same<std::remove_cvref_t<T>, bool>()) {
if (!_var.val_->is_bool()) {
return error("Could not cast to boolean.");
Expand Down
4 changes: 2 additions & 2 deletions include/rfl/flexbuf/Reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ struct Reader {
return error("Could not cast to a bytestring.");
}
const auto blob = _var.AsBlob();
return rfl::Bytestring(internal::ptr_cast<const std::byte*>(blob.data()),
blob.size());
const auto data = internal::ptr_cast<const std::byte*>(blob.data());
return rfl::Bytestring(data, data + blob.size());
} else if constexpr (std::is_same<std::remove_cvref_t<T>, bool>()) {
if (!_var.IsBool()) {
return error("Could not cast to boolean.");
Expand Down
4 changes: 2 additions & 2 deletions include/rfl/msgpack/Reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ struct Reader {
return error("Could not cast to a bytestring.");
}
const auto bin = _var.via.bin;
return rfl::Bytestring(internal::ptr_cast<const std::byte*>(bin.ptr),
bin.size);
const auto data = internal::ptr_cast<const std::byte*>(bin.ptr);
return rfl::Bytestring(data, data + bin.size);
} else if constexpr (std::is_same<std::remove_cvref_t<T>, bool>()) {
if (type != MSGPACK_OBJECT_BOOLEAN) {
return error("Could not cast to boolean.");
Expand Down
4 changes: 2 additions & 2 deletions include/rfl/ubjson/Reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ class Reader {
return error("Could not cast to bytestring.");
}
const auto vec = _var.val_->as<std::vector<uint8_t>>();
return rfl::Bytestring(internal::ptr_cast<const std::byte*>(vec.data()),
vec.size());
const auto data = internal::ptr_cast<const std::byte*>(vec.data());
return rfl::Bytestring(data, data + vec.size());
} else if constexpr (std::is_same<std::remove_cvref_t<T>, bool>()) {
if (!_var.val_->is_bool()) {
return error("Could not cast to boolean.");
Expand Down

0 comments on commit e3cb110

Please sign in to comment.