openMSX
EmptyPatch.cc
Go to the documentation of this file.
1#include "EmptyPatch.hh"
2#include "ranges.hh"
3#include <cassert>
4
5namespace openmsx {
6
7void EmptyPatch::copyBlock(size_t src, std::span<uint8_t> dst) const
8{
9 auto size = block.size();
10 if ((src + dst.size()) > size) {
11 // past end
12 if (size <= src) {
13 // start past size, only fill block
14 ranges::fill(dst, 0);
15 } else {
16 auto part1 = size - src;
17 auto part2 = dst.size() - part1;
18 assert(dst.data() != &block[src]);
19 ranges::copy(block.subspan(src, part1), dst);
20 ranges::fill(dst.subspan(part1, part2), 0);
21 }
22 } else {
23 if (dst.data() != &block[src]) {
24 // ranges::copy cannot handle overlapping regions, but in
25 // that case we don't need to copy at all
26 ranges::copy(block.subspan(src, dst.size()), dst);
27 }
28 }
29}
30
31} // namespace openmsx
void copyBlock(size_t src, std::span< uint8_t > dst) const override
Definition EmptyPatch.cc:7
This file implemented 3 utility functions:
Definition Autofire.cc:11
constexpr void fill(ForwardRange &&range, const T &value)
Definition ranges.hh:315
constexpr auto copy(InputRange &&range, OutputIter out)
Definition ranges.hh:252