diff --git a/Analyser/Static/ZXSpectrum/StaticAnalyser.cpp b/Analyser/Static/ZXSpectrum/StaticAnalyser.cpp index 723886881..4fdff30d8 100644 --- a/Analyser/Static/ZXSpectrum/StaticAnalyser.cpp +++ b/Analyser/Static/ZXSpectrum/StaticAnalyser.cpp @@ -56,7 +56,7 @@ bool IsSpectrumDisk(const std::shared_ptr &disk) { // Check the first ten bytes of the first sector for the disk format; if these are all // the same value then instead substitute a default format. std::array format; - std::copy(boot_sector->samples[0].begin(), boot_sector->samples[0].begin() + 10, format.begin()); + std::copy_n(boot_sector->samples[0].begin(), 10, format.begin()); if(std::all_of(format.begin(), format.end(), [&](const uint8_t v) { return v == format[0]; })) { format = {0x00, 0x00, 0x28, 0x09, 0x02, 0x01, 0x03, 0x02, 0x2a, 0x52}; } diff --git a/InstructionSets/M50740/Executor.cpp b/InstructionSets/M50740/Executor.cpp index 2d1581bbf..81926ed60 100644 --- a/InstructionSets/M50740/Executor.cpp +++ b/InstructionSets/M50740/Executor.cpp @@ -44,7 +44,7 @@ Executor::Executor(PortHandler &port_handler) : port_handler_(port_handler) { void Executor::set_rom(const std::vector &rom) { // Copy into place, and reset. const auto length = std::min(size_t(0x1000), rom.size()); - std::copy(rom.begin(), rom.begin() + ptrdiff_t(length), memory_.end() - length); + std::copy_n(rom.begin(), length, memory_.end() - length); reset(); } diff --git a/Machines/Acorn/Electron/Electron.cpp b/Machines/Acorn/Electron/Electron.cpp index 9fcb8f0b5..fb14d2934 100644 --- a/Machines/Acorn/Electron/Electron.cpp +++ b/Machines/Acorn/Electron/Electron.cpp @@ -665,7 +665,7 @@ private: std::size_t rom_ptr = 0; while(rom_ptr < 16384) { const std::size_t size_to_copy = std::min(16384 - rom_ptr, data.size()); - std::copy(data.begin(), data.begin() + ptrdiff_t(size_to_copy), &target[rom_ptr]); + std::copy_n(data.begin(), size_to_copy, &target[rom_ptr]); rom_ptr += size_to_copy; } diff --git a/Machines/Apple/AppleII/AppleII.cpp b/Machines/Apple/AppleII/AppleII.cpp index c8f194530..2db8429ee 100644 --- a/Machines/Apple/AppleII/AppleII.cpp +++ b/Machines/Apple/AppleII/AppleII.cpp @@ -131,8 +131,8 @@ private: uint8_t *const base_target, uint8_t *const auxiliary_target ) { - std::copy(ram_ + address, ram_ + address + count, base_target); - std::copy(aux_ram_ + address, aux_ram_ + address + count, auxiliary_target); + std::copy_n(ram_ + address, count, base_target); + std::copy_n(aux_ram_ + address, count, auxiliary_target); } private: diff --git a/Machines/Atari/ST/AtariST.cpp b/Machines/Atari/ST/AtariST.cpp index 7f2c81d8a..0ffd194ac 100644 --- a/Machines/Atari/ST/AtariST.cpp +++ b/Machines/Atari/ST/AtariST.cpp @@ -436,7 +436,7 @@ public: } void reinstall_rom_vector() { - std::copy(rom_.begin(), rom_.begin() + 8, ram_.begin()); + std::copy_n(rom_.begin(), 8, ram_.begin()); } void flush_output(int outputs) final { diff --git a/Machines/Commodore/1540/Implementation/C1540.cpp b/Machines/Commodore/1540/Implementation/C1540.cpp index 842501b83..5ce69aad1 100644 --- a/Machines/Commodore/1540/Implementation/C1540.cpp +++ b/Machines/Commodore/1540/Implementation/C1540.cpp @@ -58,7 +58,7 @@ MachineBase::MachineBase(const Personality personality, const ROM::Map &roms) : if(rom == roms.end()) { throw ROMMachine::Error::MissingROMs; } - std::copy(rom->second.begin(), rom->second.begin() + ptrdiff_t(std::min(sizeof(rom_), rom->second.size())), rom_); + std::copy_n(rom->second.begin(), std::min(sizeof(rom_), rom->second.size()), rom_); } Machine::Machine(const Personality personality, const ROM::Map &roms) : diff --git a/Machines/Enterprise/Enterprise.cpp b/Machines/Enterprise/Enterprise.cpp index 727c531cc..eceecd03d 100644 --- a/Machines/Enterprise/Enterprise.cpp +++ b/Machines/Enterprise/Enterprise.cpp @@ -192,9 +192,9 @@ public: if(source == roms.end()) { return false; } - std::copy( + std::copy_n( source->second.begin(), - source->second.begin() + std::min(destination.size(), source->second.size()), + std::min(destination.size(), source->second.size()), destination.begin() ); @@ -228,14 +228,14 @@ public: const auto basic1 = roms.find(ROM::Name::EnterpriseBASIC10Part1); const auto basic2 = roms.find(ROM::Name::EnterpriseBASIC10Part2); if(basic1 != roms.end() && basic2 != roms.end()) { - std::copy( + std::copy_n( basic1->second.begin(), - basic1->second.begin() + std::min(size_t(8192), basic1->second.size()), + std::min(size_t(8192), basic1->second.size()), &basic_[0x0000] ); - std::copy( + std::copy_n( basic2->second.begin(), - basic2->second.begin() + std::min(size_t(8192), basic2->second.size()), + std::min(size_t(8192), basic2->second.size()), &basic_[0x2000] ); } diff --git a/Machines/MasterSystem/MasterSystem.cpp b/Machines/MasterSystem/MasterSystem.cpp index 4cd24fe5e..04cb3234f 100644 --- a/Machines/MasterSystem/MasterSystem.cpp +++ b/Machines/MasterSystem/MasterSystem.cpp @@ -154,7 +154,7 @@ public: std::cerr << "No BIOS found; attempting to start cartridge directly" << std::endl; } else { has_bios_ = true; - std::copy(rom->second.begin(), rom->second.begin() + std::min(sizeof(bios_), rom->second.size()), bios_); + std::copy_n(rom->second.begin(), std::min(sizeof(bios_), rom->second.size()), bios_); } page_cartridge(); diff --git a/Machines/PCCompatible/LinearMemory.hpp b/Machines/PCCompatible/LinearMemory.hpp index 84f46dc92..8261c883f 100644 --- a/Machines/PCCompatible/LinearMemory.hpp +++ b/Machines/PCCompatible/LinearMemory.hpp @@ -59,7 +59,7 @@ struct LinearPool { // Provided for setup. void install(const uint32_t address, const uint8_t *const data, const uint32_t length) { - std::copy(data, data + length, memory.begin() + std::vector::difference_type(address)); + std::copy_n(data, length, memory.begin() + std::vector::difference_type(address)); } // Used by both DMA devices and by the CGA and MDA cards to set up their base pointers. diff --git a/Storage/Disk/DiskImage/Formats/AppleDSK.cpp b/Storage/Disk/DiskImage/Formats/AppleDSK.cpp index 02d516e87..6bc6ae330 100644 --- a/Storage/Disk/DiskImage/Formats/AppleDSK.cpp +++ b/Storage/Disk/DiskImage/Formats/AppleDSK.cpp @@ -107,9 +107,9 @@ void AppleDSK::set_tracks(const std::map> std::vector track_contents(size_t(bytes_per_sector * sectors_per_track_)); for(const auto §or_pair: sector_map) { const size_t target_address = logical_sector_for_physical_sector(sector_pair.second.address.sector); - std::copy( + std::copy_n( sector_pair.second.data.begin(), - sector_pair.second.data.begin() + bytes_per_sector, + bytes_per_sector, &track_contents[target_address*256] ); } diff --git a/Storage/Disk/DiskImage/Formats/MacintoshIMG.cpp b/Storage/Disk/DiskImage/Formats/MacintoshIMG.cpp index 7b2f75f60..3c05364d5 100644 --- a/Storage/Disk/DiskImage/Formats/MacintoshIMG.cpp +++ b/Storage/Disk/DiskImage/Formats/MacintoshIMG.cpp @@ -283,11 +283,7 @@ void MacintoshIMG::set_tracks(const std::map= track_contents.size() || sector_pair.second.data.size() != 524) continue; - std::copy( - sector_pair.second.data.begin(), - sector_pair.second.data.begin() + 524, - &track_contents[target_address] - ); + std::copy_n(sector_pair.second.data.begin(), 524, &track_contents[target_address]); } // Store for later. @@ -305,12 +301,12 @@ void MacintoshIMG::set_tracks(const std::map Storage::Disk::CPM::GetCatalogue( } const int records_to_copy = std::min(entry->number_of_records - record, records_per_sector); - std::copy( + std::copy_n( sector_contents->samples[0].begin(), - sector_contents->samples[0].begin() + records_to_copy * 128, + records_to_copy * 128, &new_file.data[entry->extent * bytes_per_catalogue_entry + size_t(record) * 128] ); record += records_to_copy; diff --git a/Storage/MassStorage/Encodings/ApplePartitionMap.hpp b/Storage/MassStorage/Encodings/ApplePartitionMap.hpp index 7970281fd..f1df5dad4 100644 --- a/Storage/MassStorage/Encodings/ApplePartitionMap.hpp +++ b/Storage/MassStorage/Encodings/ApplePartitionMap.hpp @@ -170,8 +170,8 @@ public: partition[87] = partition[15] = uint8_t(details.size); // 32 bytes are allocated for each of the following strings. - std::copy(details.name, details.name + strlen(details.name), &partition[16]); - std::copy(details.type, details.type + strlen(details.type), &partition[48]); + std::copy_n(details.name, strlen(details.name), &partition[16]); + std::copy_n(details.type, strlen(details.type), &partition[48]); partition[91] = details.status; @@ -192,7 +192,7 @@ public: /* Driver target processor. */ const char *const driver_target = volume_provider_.driver_target(); - std::copy(driver_target, driver_target + strlen(driver_target), &partition[120]); + std::copy_n(driver_target, strlen(driver_target), &partition[120]); // Various non-zero values that Apple HD SC Tool wrote are below; they are // documented as reserved officially, so I don't know their meaning. diff --git a/Storage/MassStorage/SCSI/Target.hpp b/Storage/MassStorage/SCSI/Target.hpp index 9b94cb37b..6dcec758e 100644 --- a/Storage/MassStorage/SCSI/Target.hpp +++ b/Storage/MassStorage/SCSI/Target.hpp @@ -286,10 +286,10 @@ struct Executor { 0x00, 0x00, 0x00, 0x00 /* Space for the revision level. */ }; - auto copy_string = [] (uint8_t *destination, const char *source, size_t length) -> void { + auto copy_string = [] (uint8_t *const destination, const char *const source, const size_t length) -> void { // Determine length of source and copy in as much as possible. const auto source_length = std::min(strlen(source), length); - std::copy(source, source + source_length, destination); + std::copy_n(source, source_length, destination); // Fill the rest with spaces. std::fill(&destination[source_length], &destination[length], ' '); diff --git a/Storage/Tape/Parsers/Commodore.cpp b/Storage/Tape/Parsers/Commodore.cpp index edc144dd1..54cdc8032 100644 --- a/Storage/Tape/Parsers/Commodore.cpp +++ b/Storage/Tape/Parsers/Commodore.cpp @@ -132,11 +132,7 @@ uint8_t Header::type_descriptor() const { void Header::serialise(uint8_t *const target, const uint16_t length) const { target[0] = type_descriptor(); const auto bytes_to_copy = std::min(size_t(length), data.size()); - std::copy( - data.begin(), - data.begin() + ptrdiff_t(bytes_to_copy), - target - ); + std::copy_n(data.begin(), bytes_to_copy, target); } std::unique_ptr Parser::get_next_data_body(Storage::Tape::TapeSerialiser &serialiser, const bool is_original) {