Skip to content

Commit

Permalink
std::data is C++17...
Browse files Browse the repository at this point in the history
...this project is C++14.
  • Loading branch information
Clownacy committed Aug 9, 2024
1 parent bfcb94e commit 97ec04b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions include/mdcomp/bigendian_io.hh
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,15 @@ namespace detail {
template <typename T>
static inline void Read(std::istream& in, T& val) noexcept {
alignas(alignof(T)) std::array<char, sizeof(T)> buffer;
in.read(std::data(buffer), sizeof(T));
std::memcpy(&val, std::data(buffer), sizeof(T));
in.read(buffer.data(), sizeof(T));
std::memcpy(&val, buffer.data(), sizeof(T));
}

template <typename T>
static inline void Read(std::streambuf& in, T& val) noexcept {
alignas(alignof(T)) std::array<char, sizeof(T)> buffer;
in.sgetn(std::begin(buffer), sizeof(T));
std::memcpy(&val, std::data(buffer), sizeof(T));
std::memcpy(&val, buffer.data(), sizeof(T));
}

template <typename Iter, typename T>
Expand All @@ -321,15 +321,15 @@ namespace detail {
template <typename T>
static inline void Write(std::ostream& out, T val) noexcept {
alignas(alignof(T)) std::array<char, sizeof(T)> buffer;
std::memcpy(std::data(buffer), &val, sizeof(T));
out.write(std::data(buffer), sizeof(T));
std::memcpy(buffer.data(), &val, sizeof(T));
out.write(buffer.data(), sizeof(T));
}

template <typename T>
static inline void Write(std::streambuf& out, T val) noexcept {
alignas(alignof(T)) std::array<char, sizeof(T)> buffer;
std::memcpy(std::begin(buffer), &val, sizeof(T));
out.sputn(std::data(buffer), sizeof(T));
out.sputn(buffer.data(), sizeof(T));
}

template <typename Cont, typename T>
Expand Down

0 comments on commit 97ec04b

Please sign in to comment.