diff --git a/apriltag/src/main/native/cpp/AprilTagFieldLayout.cpp b/apriltag/src/main/native/cpp/AprilTagFieldLayout.cpp index c971a488fc3..59b30ec30eb 100644 --- a/apriltag/src/main/native/cpp/AprilTagFieldLayout.cpp +++ b/apriltag/src/main/native/cpp/AprilTagFieldLayout.cpp @@ -22,7 +22,7 @@ AprilTagFieldLayout::AprilTagFieldLayout(std::string_view path) { throw std::runtime_error(fmt::format("Cannot open file: {}", path)); } - wpi::json json = wpi::json::parse(fileBuffer->begin(), fileBuffer->end()); + wpi::json json = wpi::json::parse(fileBuffer->GetCharBuffer()); for (const auto& tag : json.at("tags").get>()) { m_apriltags[tag.ID] = tag; diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MemoryBuffer.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MemoryBuffer.h index 7907c07d678..b5eaea406f2 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MemoryBuffer.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MemoryBuffer.h @@ -62,6 +62,11 @@ class MemoryBuffer { std::span GetBuffer() const { return {begin(), end()}; } + std::span GetCharBuffer() const { + return {reinterpret_cast(begin()), + reinterpret_cast(end())}; + } + /// Return an identifier for this buffer, typically the filename it was read /// from. virtual std::string_view GetBufferIdentifier() const { @@ -145,6 +150,10 @@ class WritableMemoryBuffer : public MemoryBuffer { uint8_t* begin() { return const_cast(MemoryBuffer::begin()); } uint8_t* end() { return const_cast(MemoryBuffer::end()); } std::span GetBuffer() { return {begin(), end()}; } + std::span GetCharBuffer() const { + return {reinterpret_cast(const_cast(begin())), + reinterpret_cast(const_cast(end()))}; + } static std::unique_ptr GetFile( std::string_view filename, std::error_code& ec, int64_t fileSize = -1); @@ -196,6 +205,10 @@ class WriteThroughMemoryBuffer : public MemoryBuffer { uint8_t* begin() { return const_cast(MemoryBuffer::begin()); } uint8_t* end() { return const_cast(MemoryBuffer::end()); } std::span GetBuffer() { return {begin(), end()}; } + std::span GetCharBuffer() const { + return {reinterpret_cast(const_cast(begin())), + reinterpret_cast(const_cast(end()))}; + } static std::unique_ptr GetFile( std::string_view filename, std::error_code& ec, int64_t fileSize = -1);