From 9e2c3e32b1ccd346e22b0d35ffcaf739c767a5b0 Mon Sep 17 00:00:00 2001 From: Adrian Conlon <98398945+AdrianConlon@users.noreply.github.com> Date: Fri, 1 Jul 2022 09:30:38 +0100 Subject: [PATCH] Fully switch to C++20 --- Gaming/src/Game.cpp | 4 -- M6502/HarteTest_6502/checker_t.cpp | 4 -- M6502/HarteTest_6502/opcode_test_suite_t.cpp | 19 +---- M6502/HarteTest_6502/opcode_test_suite_t.h | 17 +---- M6502/HarteTest_6502/parser_t.h | 4 -- .../HarteTest_6502/processor_test_suite_t.cpp | 18 ----- M6502/HarteTest_6502/processor_test_suite_t.h | 22 +----- M6502/HarteTest_6502/stdafx.h | 11 +-- M6502/HarteTest_6502/tests.cpp | 70 ------------------- Z80/inc/Profiler.h | 24 ------- 10 files changed, 4 insertions(+), 189 deletions(-) diff --git a/Gaming/src/Game.cpp b/Gaming/src/Game.cpp index a6ee8e5..ecb83a7 100644 --- a/Gaming/src/Game.cpp +++ b/Gaming/src/Game.cpp @@ -181,11 +181,7 @@ void Game::addJoystick(SDL_Event& e) { auto controller = std::make_shared(which); const auto joystickId = controller->getJoystickId(); m_gameControllers[which] = controller; -#if __cplusplus >= 202002L SDL_assert(m_mappedControllers.contains(joystickId)); -#else - SDL_assert(m_mappedControllers.find(joystickId) != m_mappedControllers.end()); -#endif m_mappedControllers[joystickId] = which; SDL_Log("Joystick device %d added (%zd controllers)", which, m_gameControllers.size()); } diff --git a/M6502/HarteTest_6502/checker_t.cpp b/M6502/HarteTest_6502/checker_t.cpp index 562790b..adde46c 100644 --- a/M6502/HarteTest_6502/checker_t.cpp +++ b/M6502/HarteTest_6502/checker_t.cpp @@ -208,11 +208,7 @@ void checker_t::check(test_t test) { const auto pc = cpu.PC().word; const auto start_opcode = runner().peek(pc); -#if __cplusplus >= 202002L m_undocumented = m_undocumented_opcodes.contains(start_opcode); -#else - m_undocumented = m_undocumented_opcodes.find(start_opcode) != m_undocumented_opcodes.end(); -#endif if (undocumented()) { m_valid = false; m_messages.push_back("Undocumented"); diff --git a/M6502/HarteTest_6502/opcode_test_suite_t.cpp b/M6502/HarteTest_6502/opcode_test_suite_t.cpp index cccac23..764a3c8 100644 --- a/M6502/HarteTest_6502/opcode_test_suite_t.cpp +++ b/M6502/HarteTest_6502/opcode_test_suite_t.cpp @@ -4,24 +4,7 @@ opcode_test_suite_t::opcode_test_suite_t(const std::string path) noexcept : parser_t(path) {} -#ifdef USE_COROUTINES -#if __cplusplus >= 202002L EightBit::co_generator_t opcode_test_suite_t::generator() const { for (const auto element : *this) co_yield test_t(element); -} -#else -void opcode_test_suite_t::generator(boost::coroutines2::coroutine::push_type& sink) const { - for (const auto element : *this) - sink(test_t(element)); -} -#endif -#else -std::vector opcode_test_suite_t::generate() const { - std::vector returned; - returned.reserve(size()); - for (const auto element : *this) - returned.push_back(test_t(element)); - return returned; -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/M6502/HarteTest_6502/opcode_test_suite_t.h b/M6502/HarteTest_6502/opcode_test_suite_t.h index c2acb27..37ef000 100644 --- a/M6502/HarteTest_6502/opcode_test_suite_t.h +++ b/M6502/HarteTest_6502/opcode_test_suite_t.h @@ -2,14 +2,7 @@ #include -#ifdef USE_COROUTINES -#if __cplusplus >= 202002L -# include -#else -# include -#endif -# include -#endif +#include #include "parser_t.h" #include "test_t.h" @@ -26,13 +19,5 @@ public: [[nodiscard]] auto end() const noexcept { return array().end(); } [[nodiscard]] auto size() const noexcept { return array().size(); } -#ifdef USE_COROUTINES -#if __cplusplus >= 202002L [[nodiscard]] EightBit::co_generator_t generator() const; -#else - void generator(boost::coroutines2::coroutine::push_type& sink) const; -#endif -#else - std::vector generate() const; -#endif }; diff --git a/M6502/HarteTest_6502/parser_t.h b/M6502/HarteTest_6502/parser_t.h index 122335e..8a383ba 100644 --- a/M6502/HarteTest_6502/parser_t.h +++ b/M6502/HarteTest_6502/parser_t.h @@ -19,11 +19,7 @@ public: parser_t() noexcept {} parser_t(std::string path) noexcept; -#if __cplusplus >= 202002L [[nodiscard]] constexpr std::string_view path() const noexcept { return m_path; } -#else - [[nodiscard]] std::string_view path() const noexcept { return m_path; } -#endif [[nodiscard]] const auto raw() const noexcept { return m_raw; } virtual void load(); diff --git a/M6502/HarteTest_6502/processor_test_suite_t.cpp b/M6502/HarteTest_6502/processor_test_suite_t.cpp index 2001dfc..f39672f 100644 --- a/M6502/HarteTest_6502/processor_test_suite_t.cpp +++ b/M6502/HarteTest_6502/processor_test_suite_t.cpp @@ -7,26 +7,8 @@ processor_test_suite_t::processor_test_suite_t(std::string location) noexcept : m_location(location) { } -#ifdef USE_COROUTINES -#if __cplusplus >= 202002L EightBit::co_generator_t processor_test_suite_t::generator() const { std::filesystem::path directory = location(); for (const auto& entry : std::filesystem::directory_iterator{ directory }) co_yield opcode_test_suite_t(entry.path().string()); } -#else -void processor_test_suite_t::generator(boost::coroutines2::coroutine::push_type& sink) const { - std::filesystem::path directory = location(); - for (const auto& entry : std::filesystem::directory_iterator{ directory }) - sink(opcode_test_suite_t(entry.path().string())); -} -#endif -#else -std::vector processor_test_suite_t::generate() const { - std::vector returned; - std::filesystem::path directory = location(); - for (const auto& entry : std::filesystem::directory_iterator{ directory }) - returned.push_back(opcode_test_suite_t(entry.path().string())); - return returned; -} -#endif diff --git a/M6502/HarteTest_6502/processor_test_suite_t.h b/M6502/HarteTest_6502/processor_test_suite_t.h index 2bdc3a7..3ca2179 100644 --- a/M6502/HarteTest_6502/processor_test_suite_t.h +++ b/M6502/HarteTest_6502/processor_test_suite_t.h @@ -3,15 +3,7 @@ #include #include -#ifdef USE_COROUTINES -#if __cplusplus >= 202002L -# include -#else -# include -#endif -#else -# include -#endif +#include #include "opcode_test_suite_t.h" @@ -22,19 +14,7 @@ private: public: processor_test_suite_t(std::string location) noexcept; -#if __cplusplus >= 202002L [[nodiscard]] constexpr std::string_view location() const noexcept { return m_location; } -#else - [[nodiscard]] std::string_view location() const noexcept { return m_location; } -#endif -#ifdef USE_COROUTINES -#if __cplusplus >= 202002L [[nodiscard]] EightBit::co_generator_t generator() const; -#else - void generator(boost::coroutines2::coroutine::push_type& sink) const; -#endif -#else - [[nodiscard]] std::vector generate() const; -#endif }; diff --git a/M6502/HarteTest_6502/stdafx.h b/M6502/HarteTest_6502/stdafx.h index 98bfa8a..57c1514 100644 --- a/M6502/HarteTest_6502/stdafx.h +++ b/M6502/HarteTest_6502/stdafx.h @@ -22,15 +22,6 @@ #include #include -#define USE_COROUTINES - -#ifdef USE_COROUTINES -#if __cplusplus >= 202002L -# include -#else -# include -# include -#endif -#endif +#include #include "simdjson/simdjson.h" diff --git a/M6502/HarteTest_6502/tests.cpp b/M6502/HarteTest_6502/tests.cpp index 75eab57..7d6a38b 100644 --- a/M6502/HarteTest_6502/tests.cpp +++ b/M6502/HarteTest_6502/tests.cpp @@ -4,10 +4,6 @@ #include #include -#if __cplusplus < 202002L -# include -#endif - #include "TestRunner.h" #include "checker_t.h" #include "test_t.h" @@ -30,10 +26,6 @@ int main() { checker_t checker(runner); checker.initialise(); -#ifdef USE_COROUTINES - -#if __cplusplus >= 202002L - processor_test_suite_t m6502_tests(directory); auto opcode_generator = m6502_tests.generator(); while (opcode_generator) { @@ -64,68 +56,6 @@ int main() { } } -#else - - const processor_test_suite_t m6502_tests(directory); - boost::coroutines2::coroutine::pull_type opcodes(boost::bind(&processor_test_suite_t::generator, &m6502_tests, _1)); - for (auto& opcode : opcodes) { - - const auto path = std::filesystem::path(opcode.path()); - std::cout << "Processing: " << path.filename() << "\n"; - opcode.load(); - - boost::coroutines2::coroutine::pull_type tests(boost::bind(&opcode_test_suite_t::generator, &opcode, _1)); - for (const auto& test : tests) { - - checker.check(test); - - if (checker.invalid()) { - ++invalid_opcode_count; - if (checker.unimplemented()) - ++unimplemented_opcode_count; - if (checker.undocumented()) - ++undocumented_opcode_count; - std::cout << "** Failed: " << test.name() << "\n"; - for (const auto& message : checker.messages()) - std::cout << "**** " << message << "\n"; - break; - } - } - } - -#endif - -#else - - const processor_test_suite_t m6502_tests(directory); - auto opcodes = m6502_tests.generate(); - for (auto& opcode : opcodes) { - - const auto path = std::filesystem::path(opcode.path()); - std::cout << "Processing: " << path.filename() << "\n"; - opcode.load(); - - const auto tests = opcode.generate(); - for (const auto& test : tests) { - - checker.check(test); - - if (checker.invalid()) { - ++invalid_opcode_count; - if (checker.unimplemented()) - ++unimplemented_opcode_count; - if (checker.undocumented()) - ++undocumented_opcode_count; - std::cout << "** Failed: " << test.name() << "\n"; - for (const auto& message : checker.messages()) - std::cout << "**** " << message << "\n"; - break; - } - } - } - -#endif - const auto finish_time = std::chrono::steady_clock::now(); const auto elapsed_time = finish_time - start_time; const auto seconds = std::chrono::duration_cast>(elapsed_time).count(); diff --git a/Z80/inc/Profiler.h b/Z80/inc/Profiler.h index ad0a8b5..5f7975f 100644 --- a/Z80/inc/Profiler.h +++ b/Z80/inc/Profiler.h @@ -27,8 +27,6 @@ namespace EightBit { [[nodiscard]] constexpr const auto& instructions() const { return m_instructions; } [[nodiscard]] constexpr const auto& addresses() const { return m_addresses; } -#if __cplusplus >= 202002L - [[nodiscard]] constexpr auto instructions_available() const noexcept { const auto found = std::find_if( instructions().begin(), instructions().end(), @@ -47,28 +45,6 @@ namespace EightBit { return instructions_available() || addresses_available(); } -#else - - [[nodiscard]] auto instructions_available() const noexcept { - const auto found = std::find_if( - instructions().begin(), instructions().end(), - [](const auto& value) { return value != 0; }); - return found != instructions().end(); - } - - [[nodiscard]] auto addresses_available() const noexcept { - const auto found = std::find_if( - addresses().begin(), addresses().end(), - [](const auto& value) { return value != 0; }); - return found != addresses().end(); - } - - [[nodiscard]] auto available() const noexcept { - return instructions_available() || addresses_available(); - } - -#endif - void dumpInstructionProfiles() const; void dumpAddressProfiles() const; };