1
0
mirror of https://github.com/TomHarte/CLK.git synced 2026-03-11 04:42:20 +00:00

Go further in avoiding std::function.

This commit is contained in:
Thomas Harte
2026-02-03 13:07:40 -05:00
parent 7d0264dd7a
commit b3e9448ff4
5 changed files with 18 additions and 5 deletions

View File

@@ -23,7 +23,7 @@ static void DeterminePagingFor2kCartridge(Target &target, const Storage::Cartrid
// A CommaVid start address needs to be outside of its RAM.
if(entry_address < 0x1800 || break_address < 0x1800) return;
std::function<std::size_t(uint16_t address)> high_location_mapper = [](uint16_t address) {
auto high_location_mapper = [](uint16_t address) {
address &= 0x1fff;
return size_t(address - 0x1800);
};

View File

@@ -829,7 +829,9 @@ void WD1770::posit_event(const int new_event_type) {
END_SECTION()
}
void WD1770::update_status(const std::function<void(Status &)> updater) {
template <typename FuncT>
requires std::invocable<FuncT, WD1770::Status &>
void WD1770::update_status(FuncT &&updater) {
const Status old_status = status_;
if(delegate_) {

View File

@@ -10,6 +10,8 @@
#include "Storage/Disk/Controller/MFMDiskController.hpp"
#include <concepts>
namespace WD {
/*!
@@ -112,7 +114,10 @@ private:
int distance_into_section_;
int step_direction_;
void update_status(std::function<void(Status &)> updater);
template <typename FuncT>
requires std::invocable<FuncT, Status &>
void update_status(FuncT &&);
// Events
enum Event1770: int {

View File

@@ -35,6 +35,7 @@
#include <algorithm>
#include <array>
#include <concepts>
#include <cstdint>
#include <optional>
@@ -740,7 +741,9 @@ private:
const uint8_t *processor_read_memory_map_[64]{};
uint8_t *processor_write_memory_map_[64]{};
void write_to_map(const std::function<void(uint16_t, size_t)> &store, uint16_t address, size_t length) {
template <typename FuncT>
requires std::invocable<FuncT, uint16_t, size_t>
void write_to_map(FuncT &&store, uint16_t address, size_t length) {
address >>= 10;
length >>= 10;
size_t offset = 0;

View File

@@ -13,6 +13,7 @@
#include <algorithm>
#include <atomic>
#include <cmath>
#include <concepts>
#include <optional>
#include "BufferingScanTarget.hpp"
@@ -142,11 +143,13 @@ constexpr MTLResourceOptions SharedResourceOptionsStandard =
constexpr MTLResourceOptions SharedResourceOptionsTexture =
MTLResourceCPUCacheModeWriteCombined | MTLResourceStorageModeManaged;
template <typename FuncT>
requires std::invocable<FuncT, size_t, size_t>
void range_perform(
const size_t start,
const size_t end,
const size_t size,
const std::function<void(size_t start, size_t length)> &func
const FuncT &&func
) {
if(start == end) return;
if(start < end) {