From 7a19ef71f1c24a09054c61dcd8be29fa3f6be72c Mon Sep 17 00:00:00 2001 From: Michael Jones Date: Tue, 31 Oct 2023 00:18:22 -0500 Subject: [PATCH] Various C++20 tweaks --- .clang-tidy | 8 ++-- 3rdparty/CMakeLists.txt | 16 ++++++- src/adera/ShipResources.h | 21 +++++---- src/adera/activescene/VehicleBuilder.cpp | 10 ++-- src/adera/activescene/VehicleBuilder.h | 8 ++-- src/adera/drawing/CameraController.h | 22 ++++----- src/adera/drawing_gl/flat_shader.h | 10 ++-- src/adera/drawing_gl/phong_shader.h | 10 ++-- src/adera/drawing_gl/visualizer_shader.h | 8 ++-- src/osp/activescene/active_ent.h | 4 +- src/osp/activescene/basic.h | 23 +++++---- src/osp/activescene/basic_fn.h | 28 +++++++---- src/osp/activescene/physics_fn.h | 10 ++-- src/osp/core/Resources.h | 2 +- src/osp/core/bitvector.h | 7 +-- src/osp/core/copymove_macros.h | 32 ++++++------- src/osp/core/math_2pow.h | 12 ++--- src/osp/core/resourcetypes.h | 4 +- src/osp/core/shared_string.h | 55 ++++++++-------------- src/osp/core/storage.h | 4 +- src/osp/core/strong_id.h | 13 ++++-- src/osp/core/unpack.h | 15 +++--- src/osp/drawing/draw_ent.h | 6 ++- src/osp/drawing/drawing.h | 11 +++-- src/osp/drawing/drawing_fn.h | 30 ++++++------ src/osp/drawing_gl/FullscreenTriShader.h | 5 +- src/osp/drawing_gl/rendergl.h | 15 +++--- src/osp/link/machines.h | 22 +++++---- src/osp/link/signal.h | 5 +- src/osp/tasks/builder.h | 14 +++--- src/osp/tasks/execute.h | 1 - src/osp/tasks/tasks.h | 59 ++++++++++++------------ src/osp/tasks/top_execute.cpp | 6 +-- 33 files changed, 271 insertions(+), 225 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 8ec18cb1..2b90ec83 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -5,12 +5,14 @@ Checks: 'clang-diagnostic-*, ,performance-*, ,readability-*, ,modernize-*, - ,-modernize-use-trailing-return-type, ,-modernize-use-auto, - ,-readability-uppercase-literal-suffix, - ,-readability-else-after-return, + ,-modernize-redundant-void-arg, + ,-modernize-use-trailing-return-type, ,-readability-magic-numbers, + ,-readability-named-parameter, ,-readability-identifier-length, + ,-readability-else-after-return, + ,-readability-uppercase-literal-suffix, ,-clang-analyzer-cplusplus.InnerPointer, ,-cplusplus.InnerPointer, ,-clang-diagnostic-ignored-optimization-argument, diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 95b02385..10dbd8a3 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -48,6 +48,14 @@ if(NOT OSP_USE_SYSTEM_SDL) SET(SDL_MMX OFF CACHE BOOL "" FORCE) # Old. Superceeded by SSE1, not supported by osp-magnum. SET(SDL_ASSEMBLY OFF CACHE BOOL "" FORCE) # Presumably not actually needed. Lets try more for portability than speed... + SET(SDL_IBUS OFF CACHE BOOL "" FORCE) + SET(SDL_TEST OFF CACHE BOOL "" FORCE) + SET(SDL_EVENTS OFF CACHE BOOL "" FORCE) + SET(SDL_SYSTEM_ICONV OFF CACHE BOOL "" FORCE) + + SET(SDL_DBUS ON CACHE BOOL "" FORCE) + SET(SDL_LIBUDEV ON CACHE BOOL "" FORCE) + ## # SDL Audio backend settings ## @@ -84,6 +92,8 @@ if(NOT OSP_USE_SYSTEM_SDL) # SDL Video backend settings ## SET(SDL_VIDEO ON CACHE BOOL "" FORCE) + SET(SDL_VIVANTE OFF CACHE BOOL "" FORCE) + SET(SDL_OFFSCREEN OFF CACHE BOOL "" FORCE) # Enabled video settings SET(SDL_OPENGL ON CACHE BOOL "" FORCE) @@ -108,8 +118,10 @@ if(NOT OSP_USE_SYSTEM_SDL) SET(SDL_FILE ON CACHE BOOL "" FORCE) # Needed for Mac OSX SET(SDL_LOADSO ON CACHE BOOL "" FORCE) - SET(SDL_JOYSTICK ON CACHE BOOL "" FORCE) - SET(SDL_VIRTUAL_JOYSTICK ON CACHE BOOL "" FORCE) + SET(SDL_HIDAPI OFF CACHE BOOL "" FORCE) + SET(SDL_HIDAPI_JOYSTICK OFF CACHE BOOL "" FORCE) + SET(SDL_JOYSTICK OFF CACHE BOOL "" FORCE) + SET(SDL_VIRTUAL_JOYSTICK OFF CACHE BOOL "" FORCE) SET(LIBSAMPLERATE ON CACHE BOOL "" FORCE) SET(LIBSAMPLERATE_SHARED ON CACHE BOOL "" FORCE) diff --git a/src/adera/ShipResources.h b/src/adera/ShipResources.h index d04de4bf..6cd342f3 100644 --- a/src/adera/ShipResources.h +++ b/src/adera/ShipResources.h @@ -23,13 +23,16 @@ * SOFTWARE. */ #pragma once -#include -#include //#include #include #include +#include + +#include +#include + namespace adera::active::machines { @@ -86,7 +89,7 @@ struct ShipResourceType const std::string m_displayName; // 1/(QPU) is the smallest representable quantity of this resource; must be a power of 2 - const uint64_t m_quantaPerUnit; + const std::uint64_t m_quantaPerUnit; // The volume (in m^3) of one unit of this resource const float m_volumePerUnit; @@ -98,35 +101,35 @@ struct ShipResourceType const float m_density; // Compute the volume of the specified quantity of resource - constexpr double resource_volume(uint64_t quantity) const + constexpr double resource_volume(std::uint64_t quantity) const { double units = static_cast(quantity) / m_quantaPerUnit; return units * m_volumePerUnit; } // Compute the mass of the specified quantity of resource - constexpr double resource_mass(uint64_t quantity) const + constexpr double resource_mass(std::uint64_t quantity) const { double units = static_cast(quantity) / m_quantaPerUnit; return units * m_massPerUnit; } // Compute the quantity of resource that fits in the specified volume - constexpr uint64_t resource_capacity(double volume) const + constexpr std::uint64_t resource_capacity(double volume) const { double units = volume / m_volumePerUnit; - return static_cast(units * m_quantaPerUnit); + return static_cast(units * m_quantaPerUnit); } // Compute the quantity of resource that masses the specified amount - constexpr uint64_t resource_quantity(double mass) const + constexpr std::uint64_t resource_quantity(double mass) const { double units = mass / m_massPerUnit; return static_cast(units * m_quantaPerUnit); } ShipResourceType(std::string identifier, std::string displayName, - uint64_t quantaPerUnit, float volume, float mass, float density) + std::uint64_t quantaPerUnit, float volume, float mass, float density) : m_identifier(std::move(identifier)) , m_displayName(std::move(displayName)) , m_quantaPerUnit(quantaPerUnit) diff --git a/src/adera/activescene/VehicleBuilder.cpp b/src/adera/activescene/VehicleBuilder.cpp index 9b927015..5b104583 100644 --- a/src/adera/activescene/VehicleBuilder.cpp +++ b/src/adera/activescene/VehicleBuilder.cpp @@ -28,6 +28,8 @@ #include #include +#include + namespace adera { @@ -66,7 +68,7 @@ void VehicleBuilder::set_prefabs(std::initializer_list const& setPref } } -WeldId VehicleBuilder::weld(osp::ArrayView toWeld) +WeldId VehicleBuilder::weld(std::span toWeld) { WeldId const weld = m_data->m_weldIds.create(); m_data->m_weldToParts.ids_reserve(m_data->m_weldIds.capacity()); @@ -79,7 +81,7 @@ WeldId VehicleBuilder::weld(osp::ArrayView toWeld) m_data->m_partToWeld[set.m_part] = weld; (*pPartInWeld) = set.m_part; - std::advance(pPartInWeld, 1); + ++pPartInWeld; } return weld; @@ -87,7 +89,7 @@ WeldId VehicleBuilder::weld(osp::ArrayView toWeld) void VehicleBuilder::index_prefabs() { - for (unsigned int i = 0; i < m_pResources->ids(gc_importer).capacity(); ++i) + for (auto const i : std::views::iota(0u, m_pResources->ids(gc_importer).capacity())) { auto const resId = osp::ResId(i); if ( ! m_pResources->ids(gc_importer).exists(resId)) @@ -101,7 +103,7 @@ void VehicleBuilder::index_prefabs() continue; // No prefab data } - for (osp::PrefabId j = 0; j < pPrefabData->m_prefabNames.size(); ++j) + for (osp::PrefabId const j : std::views::iota(0u, pPrefabData->m_prefabNames.size())) { osp::ResIdOwner_t owner = m_pResources->owner_create(gc_importer, resId); diff --git a/src/adera/activescene/VehicleBuilder.h b/src/adera/activescene/VehicleBuilder.h index d848ac03..e85a6c46 100644 --- a/src/adera/activescene/VehicleBuilder.h +++ b/src/adera/activescene/VehicleBuilder.h @@ -36,10 +36,12 @@ #include #include -#include #include #include #include +#include + +#include namespace adera { @@ -133,11 +135,11 @@ class VehicleBuilder void set_prefabs(std::initializer_list const& setPrefab); - WeldId weld(osp::ArrayView toWeld); + WeldId weld(std::span toWeld); WeldId weld(std::initializer_list const& toWeld) { - return weld(osp::arrayView(toWeld)); + return weld(std::span{toWeld}); } osp::Matrix4 align_attach(PartId partA, std::string_view attachA, diff --git a/src/adera/drawing/CameraController.h b/src/adera/drawing/CameraController.h index c5fde136..1f2c55dd 100644 --- a/src/adera/drawing/CameraController.h +++ b/src/adera/drawing/CameraController.h @@ -39,17 +39,17 @@ struct ACtxCameraController ACtxCameraController(osp::input::UserInputHandler &rInput) : m_controls(&rInput) - , m_btnOrbit( m_controls.button_subscribe("cam_orbit")) - , m_btnRotUp( m_controls.button_subscribe("ui_up")) - , m_btnRotDn( m_controls.button_subscribe("ui_dn")) - , m_btnRotLf( m_controls.button_subscribe("ui_lf")) - , m_btnRotRt( m_controls.button_subscribe("ui_rt")) - , m_btnMovFd( m_controls.button_subscribe("cam_fd")) - , m_btnMovBk( m_controls.button_subscribe("cam_bk")) - , m_btnMovLf( m_controls.button_subscribe("cam_lf")) - , m_btnMovRt( m_controls.button_subscribe("cam_rt")) - , m_btnMovUp( m_controls.button_subscribe("cam_up")) - , m_btnMovDn( m_controls.button_subscribe("cam_dn")) + , m_btnOrbit(m_controls.button_subscribe("cam_orbit")) + , m_btnRotUp(m_controls.button_subscribe("ui_up")) + , m_btnRotDn(m_controls.button_subscribe("ui_dn")) + , m_btnRotLf(m_controls.button_subscribe("ui_lf")) + , m_btnRotRt(m_controls.button_subscribe("ui_rt")) + , m_btnMovFd(m_controls.button_subscribe("cam_fd")) + , m_btnMovBk(m_controls.button_subscribe("cam_bk")) + , m_btnMovLf(m_controls.button_subscribe("cam_lf")) + , m_btnMovRt(m_controls.button_subscribe("cam_rt")) + , m_btnMovUp(m_controls.button_subscribe("cam_up")) + , m_btnMovDn(m_controls.button_subscribe("cam_dn")) { } ACtxCameraController(ACtxCameraController const& copy) = delete; ACtxCameraController(ACtxCameraController&& move) = default; diff --git a/src/adera/drawing_gl/flat_shader.h b/src/adera/drawing_gl/flat_shader.h index be22dc49..d63daab5 100644 --- a/src/adera/drawing_gl/flat_shader.h +++ b/src/adera/drawing_gl/flat_shader.h @@ -28,6 +28,8 @@ #include +#include + namespace adera::shader { @@ -109,11 +111,11 @@ inline void sync_drawent_flat(osp::draw::DrawEnt ent, ArgsForSyncDrawEntFlat con } } -template +template SENT_T> void sync_drawent_flat( - ITA_T const& first, - ITB_T const& last, - ArgsForSyncDrawEntFlat const args) + IT_T const& first, + SENT_T const& last, + ArgsForSyncDrawEntFlat const args) { std::for_each(first, last, [&args] (osp::draw::DrawEnt const ent) { diff --git a/src/adera/drawing_gl/phong_shader.h b/src/adera/drawing_gl/phong_shader.h index d067fad4..fadd182c 100644 --- a/src/adera/drawing_gl/phong_shader.h +++ b/src/adera/drawing_gl/phong_shader.h @@ -28,6 +28,8 @@ #include +#include + namespace adera::shader { @@ -110,11 +112,11 @@ inline void sync_drawent_phong(osp::draw::DrawEnt ent, ArgsForSyncDrawEntPhong c } } -template +template SENT_T> void sync_drawent_phong( - ITA_T const& first, - ITB_T const& last, - ArgsForSyncDrawEntPhong const args) + IT_T const& first, + SENT_T const& last, + ArgsForSyncDrawEntPhong const args) { std::for_each(first, last, [&args] (osp::draw::DrawEnt const ent) { diff --git a/src/adera/drawing_gl/visualizer_shader.h b/src/adera/drawing_gl/visualizer_shader.h index b9ae51bf..8c7b762a 100644 --- a/src/adera/drawing_gl/visualizer_shader.h +++ b/src/adera/drawing_gl/visualizer_shader.h @@ -28,6 +28,8 @@ #include +#include + namespace adera::shader { @@ -82,10 +84,10 @@ inline void sync_drawent_visualizer( } } } -template +template SENT_T> static void sync_drawent_visualizer( - ITA_T const& first, - ITB_T const& last, + IT_T const& first, + SENT_T const& last, osp::draw::DrawEntSet_t const& hasMaterial, osp::draw::RenderGroup::DrawEnts_t& rStorage, ACtxDrawMeshVisualizer& rData) diff --git a/src/osp/activescene/active_ent.h b/src/osp/activescene/active_ent.h index 9d65eaf6..0175b8dd 100644 --- a/src/osp/activescene/active_ent.h +++ b/src/osp/activescene/active_ent.h @@ -26,9 +26,11 @@ #include "../core/strong_id.h" +#include + namespace osp::active { -using ActiveEnt = StrongId; +using ActiveEnt = StrongId; } // namespace osp::active diff --git a/src/osp/activescene/basic.h b/src/osp/activescene/basic.h index 648d86ff..7e5c1d5d 100644 --- a/src/osp/activescene/basic.h +++ b/src/osp/activescene/basic.h @@ -35,6 +35,9 @@ #include // for lgrn::IdRegistryStl #include +#include + +#include namespace osp::active { @@ -58,7 +61,7 @@ struct ACompName std::string m_name; }; -using TreePos_t = uint32_t; +using TreePos_t = std::uint32_t; struct ACtxSceneGraph { @@ -66,15 +69,15 @@ struct ACtxSceneGraph // descendants is positioned directly after it within the array. // Example for tree structure "A( B(C(D)), E(F(G(H,I))) )" // * Descendant Count array: [A:8, B:2, C:1, D:0, E:4, F:3, G:2, H:0, I:0] - osp::KeyedVec m_treeToEnt{{lgrn::id_null()}}; - osp::KeyedVec m_treeDescendants{std::initializer_list{0}}; + osp::KeyedVec m_treeToEnt{{lgrn::id_null()}}; + osp::KeyedVec m_treeDescendants{std::initializer_list{0}}; - osp::KeyedVec m_entParent; - osp::KeyedVec m_entToTreePos; + osp::KeyedVec m_entParent; + osp::KeyedVec m_entToTreePos; - std::vector m_delete; + std::vector m_delete; - void resize(std::size_t ents) + void resize(std::size_t const ents) { m_treeToEnt .reserve(ents); m_treeDescendants .reserve(ents); @@ -96,8 +99,8 @@ struct ACtxBasic ACompTransformStorage_t m_transform; }; -template -void update_delete_basic(ACtxBasic &rCtxBasic, IT_T first, IT_T const& last) +template SENT_T> +void update_delete_basic(ACtxBasic &rCtxBasic, IT_T first, SENT_T const& last) { while (first != last) { @@ -109,7 +112,7 @@ void update_delete_basic(ACtxBasic &rCtxBasic, IT_T first, IT_T const& last) } - std::advance(first, 1); + ++first; } } diff --git a/src/osp/activescene/basic_fn.h b/src/osp/activescene/basic_fn.h index 0124fe26..01939426 100644 --- a/src/osp/activescene/basic_fn.h +++ b/src/osp/activescene/basic_fn.h @@ -31,6 +31,7 @@ #include #include +#include namespace osp::active { @@ -109,7 +110,14 @@ class ChildIterator return *this; } - friend auto operator<=>(ChildIterator const& lhs, ChildIterator const& rhs) noexcept = default; + ChildIterator operator++(int) noexcept + { + ChildIterator tmp = *this; + this->operator++(); + return tmp; + } + + friend constexpr std::strong_ordering operator<=>(ChildIterator const& lhs, ChildIterator const& rhs) noexcept = default; value_type operator*() const noexcept { @@ -158,14 +166,14 @@ class SysSceneGraph * in the same range. All given entities should be a root of a * unique subtree. */ - template - static void cut(ACtxSceneGraph& rScnGraph, ITA_T first, ITB_T const& last); + template SENT_T> + static void cut(ACtxSceneGraph& rScnGraph, IT_T first, SENT_T const& last); /** * @brief Add multiple entities and their descendents to a delete queue */ - template - static void queue_delete_entities(ACtxSceneGraph& rScnGraph, ActiveEntVec_t &rDelete, ITA_T const& first, ITB_T const& last); + template SENT_T> + static void queue_delete_entities(ACtxSceneGraph& rScnGraph, ActiveEntVec_t &rDelete, IT_T const& first, SENT_T const& last); private: @@ -173,8 +181,8 @@ class SysSceneGraph }; // class SysSceneGraph -template -void SysSceneGraph::cut(ACtxSceneGraph& rScnGraph, ITA_T first, ITB_T const& last) +template SENT_T> +void SysSceneGraph::cut(ACtxSceneGraph& rScnGraph, IT_T first, SENT_T const& last) { if (first == last) { @@ -187,14 +195,14 @@ void SysSceneGraph::cut(ACtxSceneGraph& rScnGraph, ITA_T first, ITB_T const& las rScnGraph.m_delete.push_back(pos); - std::advance(first, 1); + ++first; } do_delete(rScnGraph); } -template -void SysSceneGraph::queue_delete_entities(ACtxSceneGraph& rScnGraph, ActiveEntVec_t &rDelete, ITA_T const& first, ITB_T const& last) +template SENT_T> +void SysSceneGraph::queue_delete_entities(ACtxSceneGraph& rScnGraph, ActiveEntVec_t &rDelete, IT_T const& first, SENT_T const& last) { std::for_each(first, last, [&] (ActiveEnt const ent) { diff --git a/src/osp/activescene/physics_fn.h b/src/osp/activescene/physics_fn.h index 55d7fc59..98c5aed5 100644 --- a/src/osp/activescene/physics_fn.h +++ b/src/osp/activescene/physics_fn.h @@ -27,6 +27,8 @@ #include "physics.h" #include "basic.h" +#include + namespace osp::active { @@ -53,13 +55,13 @@ class SysPhysics Matrix3& rInertiaTensor, Matrix4 const& currentTf = {}); - template - static void update_delete_phys(ACtxPhysics& rCtxPhys, IT_T const& first, ITB_T const& last); + template SENT_T> + static void update_delete_phys(ACtxPhysics& rCtxPhys, IT_T const& first, SENT_T const& last); }; -template -void SysPhysics::update_delete_phys(ACtxPhysics& rCtxPhys, IT_T const& first, ITB_T const& last) +template SENT_T> +void SysPhysics::update_delete_phys(ACtxPhysics& rCtxPhys, IT_T const& first, SENT_T const& last) { rCtxPhys.m_mass.remove(first, last); } diff --git a/src/osp/core/Resources.h b/src/osp/core/Resources.h index 20dae9bd..d71a2766 100644 --- a/src/osp/core/Resources.h +++ b/src/osp/core/Resources.h @@ -215,7 +215,7 @@ void Resources::data_register(ResTypeId typeId) std::vector &rTypes = rPerResType.m_resDataTypes; // Check to make sure type isn't already registered - assert(std::find(rTypes.begin(), rTypes.end(), type) == rTypes.end()); + assert(std::ranges::find(rTypes, type) == rTypes.end()); rTypes.push_back(type); rPerResType.m_resData.emplace_back(res_container_t{}); diff --git a/src/osp/core/bitvector.h b/src/osp/core/bitvector.h index 2f399df8..c0805f9d 100644 --- a/src/osp/core/bitvector.h +++ b/src/osp/core/bitvector.h @@ -26,16 +26,17 @@ #include -#include #include +#include + namespace osp { -using bitint_t = uint64_t; +using bitint_t = std::uint64_t; using BitVector_t = lgrn::BitView< std::vector >; -inline void bitvector_resize(BitVector_t &rBitVector, std::size_t size) +inline void bitvector_resize(BitVector_t &rBitVector, std::size_t const size) { rBitVector.ints().resize(size / 64 + (size % 64 != 0), 0); } diff --git a/src/osp/core/copymove_macros.h b/src/osp/core/copymove_macros.h index 16b18abd..a556ee65 100644 --- a/src/osp/core/copymove_macros.h +++ b/src/osp/core/copymove_macros.h @@ -27,30 +27,30 @@ #define OSP_MOVE_COPY_CTOR_ASSIGN(type) \ Type (Type const& copy) = default; \ Type (Type&& move) = default; \ - Type& operator= (Type const& copy) = default; \ - Type& operator= (Type&& move) = default; + Type& operator= (Type const& copy)& = default; \ + Type& operator= (Type&& move)& = default; #define OSP_MOVE_ONLY_CTOR_ASSIGN(Type) \ Type (Type const& copy) = delete; \ Type (Type&& move) = default; \ - Type& operator= (Type const& copy) = delete; \ - Type& operator= (Type&& move) = default; + Type& operator= (Type const& copy)& = delete; \ + Type& operator= (Type&& move)& = default; -#define OSP_MOVE_ONLY_CTOR(Type) \ - Type (Type const& copy) = delete; \ +#define OSP_MOVE_ONLY_CTOR(Type) \ + Type (Type const& copy) = delete; \ Type (Type&& move) = default; -#define OSP_MOVE_COPY_CTOR_ASSIGN_CONSTEXPR_NOEXCEPT(Type) \ - constexpr Type (Type const& copy) noexcept = default; \ - constexpr Type (Type&& move) noexcept = default; \ - constexpr Type& operator= (Type const& copy) noexcept = default; \ - constexpr Type& operator= (Type&& move) noexcept = default; +#define OSP_MOVE_COPY_CTOR_ASSIGN_CONSTEXPR_NOEXCEPT(Type) \ + constexpr Type (Type const& copy) noexcept = default; \ + constexpr Type (Type&& move) noexcept = default; \ + constexpr Type& operator= (Type const& copy)& noexcept = default; \ + constexpr Type& operator= (Type&& move)& noexcept = default; -#define OSP_MOVE_ONLY_CTOR_ASSIGN_CONSTEXPR_NOEXCEPT(Type) \ - constexpr Type (Type const& copy) noexcept = delete; \ - constexpr Type (Type&& move) noexcept = default; \ - constexpr Type& operator= (Type const& copy) noexcept = delete; \ - constexpr Type& operator= (Type&& move) noexcept = default; +#define OSP_MOVE_ONLY_CTOR_ASSIGN_CONSTEXPR_NOEXCEPT(Type) \ + constexpr Type (Type const& copy) noexcept = delete; \ + constexpr Type (Type&& move) noexcept = default; \ + constexpr Type& operator= (Type const& copy)& noexcept = delete; \ + constexpr Type& operator= (Type&& move)& noexcept = default; #define OSP_MOVE_ONLY_CTOR_CONSTEXPR_NOEXCEPT(Type) \ constexpr Type (Type const& copy) noexcept = delete; \ diff --git a/src/osp/core/math_2pow.h b/src/osp/core/math_2pow.h index 152bfd9d..f299baca 100644 --- a/src/osp/core/math_2pow.h +++ b/src/osp/core/math_2pow.h @@ -25,29 +25,29 @@ #pragma once -#include +#include #include +#include + namespace osp::math { /** * @return Integer 2^exponent */ -template +template constexpr INT_T int_2pow(int exponent) noexcept { - static_assert(std::is_integral::value, "Integer required"); return INT_T(1) << exponent; } /** * @return true if value is power of two */ -template +template constexpr bool is_power_of_2(INT_T value) noexcept { - static_assert(std::is_integral_v, "Integer required"); // Test to see if the value contains more than 1 set bit return !(value == 0) && !(value & (value - 1)); } @@ -63,7 +63,7 @@ constexpr bool is_power_of_2(INT_T value) noexcept * * @return value multiplied by 2^exponent */ -template +template constexpr T mul_2pow(T value, int exponent) noexcept { // Multiply by power of two if exponent is positive diff --git a/src/osp/core/resourcetypes.h b/src/osp/core/resourcetypes.h index 4c5c1829..09bc3f78 100644 --- a/src/osp/core/resourcetypes.h +++ b/src/osp/core/resourcetypes.h @@ -46,8 +46,8 @@ class ResourceContainer public: // Required for std::is_copy_assignable to work properly inside of entt::any ResourceContainer() = default; - ResourceContainer(ResourceContainer const& copy) = delete; - ResourceContainer(ResourceContainer&& move) = default; + ResourceContainer(ResourceContainer const& copy) noexcept = delete; + ResourceContainer(ResourceContainer&& move) noexcept = default; template T& emplace(ResId id, ARGS_T&& ... args) diff --git a/src/osp/core/shared_string.h b/src/osp/core/shared_string.h index 31fd8416..e9cbeaac 100644 --- a/src/osp/core/shared_string.h +++ b/src/osp/core/shared_string.h @@ -29,12 +29,12 @@ #include "string_concat.h" // for string_data(), string_size() #include // for std::shared_ptr +#include // for std::forward_iterator, std::sentinal_for #include // for std::forward #include // for std::invalid_argument #include // for std::hash #include // for std::basic_string_view #include // for std::is_nothrow_default_constructible_v, etc - #include // for std::size_t namespace osp @@ -138,9 +138,11 @@ class BasicSharedString : public std::basic_string_view /** * @brief Constructs a new SharedString with newly allocated storage initialized with the provided data. + * + * Note that the provided iterator must be forward or better, so that the distance can be calculated before traversing. */ - template - static BasicSharedString create(IT_T&&, IT_T&&) noexcept(false); // allocates + template SENT_T> + static BasicSharedString create(IT_T const&, SENT_T const&) noexcept(false); // allocates /** * @brief Constructs a new SharedString with newly allocated storage initialized with the provided data. @@ -175,38 +177,37 @@ class BasicSharedString : public std::basic_string_view static constexpr BasicSharedString create_reference(ViewBase_t) noexcept( std::is_nothrow_default_constructible_v ); -#if defined(__cpp_impl_three_way_comparison) +private: // hidden friend idiom /** * @brief threeway comparison operator for shared strings. Only compares string data, not lifetime. */ - constexpr decltype(auto) operator<=>(BasicSharedString const& rhs) + friend constexpr std::strong_ordering operator<=>(BasicSharedString const& lhs, BasicSharedString const& rhs) noexcept { - return ViewBase_t(*this) <=> ViewBase_t(rhs); + return ViewBase_t(lhs) <=> ViewBase_t(rhs); } /** * @brief threeway comparison operator for shared strings. Only compares string data, not lifetime. */ - constexpr decltype(auto) operator<=>(ViewBase_t const& rhs) + friend constexpr std::strong_ordering operator<=>(BasicSharedString const& lhs, ViewBase_t const rhs) noexcept { - return ViewBase_t(*this) <=> rhs; + return ViewBase_t(lhs) <=> rhs; } -#endif // defined(__cpp_impl_three_way_comparison) /** * @brief Equality operator for shared strings. Only compares string data, not lifetime. */ - constexpr bool operator==(BasicSharedString const& rhs) + friend constexpr bool operator==(BasicSharedString const& lhs, BasicSharedString const& rhs) noexcept { - return ViewBase_t(*this) == ViewBase_t(rhs); + return ViewBase_t(lhs) == ViewBase_t(rhs); } /** * @brief Equality operator for shared strings. Only compares string data, not lifetime. */ - constexpr bool operator==(ViewBase_t const& rhs) + friend constexpr bool operator==(BasicSharedString const& lhs, ViewBase_t const rhs) noexcept { - return ViewBase_t(*this) == rhs; + return ViewBase_t(lhs) == rhs; } protected: @@ -225,12 +226,7 @@ class BasicSharedString : public std::basic_string_view //----------------------------------------------------------------------------- -#if defined(__cpp_lib_shared_ptr_arrays) && 201707 <= __cpp_lib_shared_ptr_arrays -using SharedStringLifetime_t = std::shared_ptr; -#else -// missing std::shared_ptr... -using SharedStringLifetime_t = std::shared_ptr; -#endif +using SharedStringLifetime_t = std::shared_ptr; /** * The concrete implementation. @@ -267,8 +263,8 @@ constexpr BasicSharedString::operator std::basic_string - template -inline auto BasicSharedString::create(IT_T && begin, IT_T && end) noexcept(false) // allocates + template SENT_T> +inline auto BasicSharedString::create(IT_T const& begin, SENT_T const& end) noexcept(false) // allocates -> BasicSharedString { // Determine size @@ -295,17 +291,10 @@ inline auto BasicSharedString::create(IT_T && begin, IT_T && } // Make space to copy the string -#if defined(__cpp_lib_smart_ptr_for_overwrite) auto buf = std::make_shared_for_overwrite(size); -#elif defined(__cpp_lib_shared_ptr_arrays) && 201707 <= __cpp_lib_shared_ptr_arrays - // avoid initilization of allocated array... - std::shared_ptr buf{new CHAR_T[size]}; -#else - std::shared_ptr buf(new CHAR_T[size]); -#endif // Do the copy - std::copy_n(std::forward(begin), size, buf.get()); + std::copy(begin, end, buf.get()); // Construct prior to SharedString constructor to avoid // ABI specific parameter passing order problems. @@ -329,15 +318,7 @@ inline auto BasicSharedString::create_from_parts(STRS_T && . } // Make space to copy the string -#if defined(__cpp_lib_smart_ptr_for_overwrite) auto buf = std::make_shared_for_overwrite(size); -#elif defined(__cpp_lib_shared_ptr_arrays) && 201707 <= __cpp_lib_shared_ptr_arrays - // avoid initilization of allocated array... - std::shared_ptr buf{new CHAR_T[size]}; -#else - std::shared_ptr buf(new CHAR_T[size]); -#endif - { auto * p = buf.get(); diff --git a/src/osp/core/storage.h b/src/osp/core/storage.h index 6d42a69a..90edb8e0 100644 --- a/src/osp/core/storage.h +++ b/src/osp/core/storage.h @@ -47,11 +47,11 @@ void storage_assign(entt::basic_storage &rStorage, ENT_T const en { if (rStorage.contains(ent)) { - rStorage.get(ent) = std::move(*value); + rStorage.get(ent) = *std::move(value); } else { - rStorage.emplace(ent, std::move(*value)); + rStorage.emplace(ent, *std::move(value)); } } else diff --git a/src/osp/core/strong_id.h b/src/osp/core/strong_id.h index b9d2cbc7..381739d4 100644 --- a/src/osp/core/strong_id.h +++ b/src/osp/core/strong_id.h @@ -24,10 +24,12 @@ */ #pragma once -#include +#include + +#include #include // light-ish header that happens to include std::hash -#include +#include namespace osp { @@ -40,7 +42,7 @@ namespace osp * @tparam INT_T Wrapped integer type, usually unsigned * @tparam DUMMY_T Dummy used to make separate unique types, avoids needing inheritance */ -template +template struct StrongId { using entity_type = INT_T; // Name used for entt compatibility @@ -76,7 +78,7 @@ struct StrongId } // namespace osp // std::hash support for unordered containers -template +template struct std::hash> { constexpr auto operator() (osp::StrongId const& key) const { @@ -86,7 +88,8 @@ struct std::hash> { // Longeron++ underlying_int_type template -struct lgrn::underlying_int_type< TYPE_T, std::enable_if_t< std::is_integral_v > > + requires std::is_integral_v +struct lgrn::underlying_int_type< TYPE_T > { using type = typename TYPE_T::entity_type; }; diff --git a/src/osp/core/unpack.h b/src/osp/core/unpack.h index 4c893914..55527660 100644 --- a/src/osp/core/unpack.h +++ b/src/osp/core/unpack.h @@ -24,10 +24,12 @@ */ #pragma once -#include +#include #include #include +#include + namespace osp { @@ -35,17 +37,18 @@ namespace osp * @brief Create a structured binding-compatible type from a contiguous * container. A c-array is used. */ -template +template constexpr auto& unpack(RANGE_T &rIn) { - using ptr_t = decltype(rIn.data()); + using ptr_t = decltype(std::ranges::data(rIn)); using type_t = std::remove_pointer_t; - assert(N <= rIn.size()); - return *reinterpret_cast(std::data(rIn)); + assert(N <= std::ranges::size(rIn)); + return *reinterpret_cast(std::ranges::data(rIn)); } -template +template + requires requires(CONTAINER_T & rIn){ rIn.resize(N); } constexpr auto& resize_then_unpack(CONTAINER_T &rIn) { rIn.resize(N); diff --git a/src/osp/drawing/draw_ent.h b/src/osp/drawing/draw_ent.h index 1b9e8b01..56bd70e1 100644 --- a/src/osp/drawing/draw_ent.h +++ b/src/osp/drawing/draw_ent.h @@ -26,11 +26,13 @@ #include "../core/strong_id.h" +#include + namespace osp::draw { -using DrawEnt = StrongId; +using DrawEnt = StrongId; -using MaterialId = StrongId; +using MaterialId = StrongId; } // namespace osp::draw diff --git a/src/osp/drawing/drawing.h b/src/osp/drawing/drawing.h index 60e7800a..0f6846e9 100644 --- a/src/osp/drawing/drawing.h +++ b/src/osp/drawing/drawing.h @@ -42,6 +42,11 @@ #include #include // for lgrn::IdRegistryStl +#include + +#include +#include + namespace osp::draw { @@ -59,14 +64,14 @@ struct Material * * The renderer will synchronize this component with a GPU resource */ -enum class MeshId : uint32_t { }; +enum class MeshId : std::uint32_t { }; /** * @brief Texture component that describes the appearance of an entity * * The renderer will synchronize this component with a GPU resource */ -enum class TexId : uint32_t { }; +enum class TexId : std::uint32_t { }; using MeshRefCount_t = lgrn::IdRefCount; @@ -131,7 +136,7 @@ struct ACtxSceneRender m_diffuseTex .resize(size); m_mesh .resize(size); - for (uint32_t matInt : m_materialIds.bitview().zeros()) + for (std::uint32_t matInt : m_materialIds.bitview().zeros()) { bitvector_resize(m_materials[MaterialId(matInt)].m_ents, size); } diff --git a/src/osp/drawing/drawing_fn.h b/src/osp/drawing/drawing_fn.h index 6ba54561..8ca27778 100644 --- a/src/osp/drawing/drawing_fn.h +++ b/src/osp/drawing/drawing_fn.h @@ -29,6 +29,8 @@ #include "../activescene/basic.h" #include "../activescene/basic_fn.h" +#include + namespace osp::draw { @@ -178,16 +180,15 @@ class SysRender DrawTransforms_t& rDrawTf; }; - template + template SENT_T, typename FUNC_T = UpdDrawTransformNoOp> static void update_draw_transforms( ArgsForUpdDrawTransform args, IT_T first, - ITB_T const& last, + SENT_T const& last, FUNC_T func = {}); - template - static void update_delete_drawing( - ACtxSceneRender& rCtxScnRdr, ACtxDrawing& rCtxDrawing, IT_T const& first, IT_T const& last); + template SENT_T> + static void update_delete_drawing(ACtxSceneRender& rCtxScnRdr, ACtxDrawing& rCtxDrawing, IT_T first, SENT_T const& last); static MeshIdOwner_t add_drawable_mesh(ACtxDrawing& rDrawing, ACtxDrawingRes& rDrawingRes, Resources& rResources, PkgId const pkg, std::string_view const name); @@ -221,11 +222,11 @@ void SysRender::needs_draw_transforms( } } -template +template SENT_T, typename FUNC_T> void SysRender::update_draw_transforms( ArgsForUpdDrawTransform args, IT_T first, - ITB_T const& last, + SENT_T const& last, FUNC_T func) { static constexpr Matrix4 const identity{}; @@ -239,7 +240,7 @@ void SysRender::update_draw_transforms( update_draw_transforms_recurse(args, ent, identity, true, func); } - std::advance(first, 1); + ++first; } } @@ -264,7 +265,7 @@ void SysRender::update_draw_transforms_recurse( args.rDrawTf[drawEnt] = entDrawTf; } - for (ActiveEnt entChild : SysSceneGraph::children(args.scnGraph, ent)) + for (ActiveEnt const entChild : SysSceneGraph::children(args.scnGraph, ent)) { if (args.needDrawTf.test(std::size_t(entChild))) { @@ -273,7 +274,6 @@ void SysRender::update_draw_transforms_recurse( } } - template void remove_refcounted( DrawEnt const ent, STORAGE_T &rStorage, REFCOUNT_T &rRefcount) @@ -285,16 +285,18 @@ void remove_refcounted( } } -template +template SENT_T> void SysRender::update_delete_drawing( - ACtxSceneRender& rCtxScnRdr, ACtxDrawing& rCtxDrawing, IT_T const& first, IT_T const& last) + ACtxSceneRender& rCtxScnRdr, ACtxDrawing& rCtxDrawing, IT_T first, SENT_T const& last) { - for (auto it = first; it != last; std::advance(it, 1)) + while(first != last) { - DrawEnt const drawEnt = *it; + DrawEnt const drawEnt = *first; remove_refcounted(drawEnt, rCtxScnRdr.m_diffuseTex, rCtxDrawing.m_texRefCounts); remove_refcounted(drawEnt, rCtxScnRdr.m_mesh, rCtxDrawing.m_meshRefCounts); + + ++first; } } diff --git a/src/osp/drawing_gl/FullscreenTriShader.h b/src/osp/drawing_gl/FullscreenTriShader.h index baca9e3a..c4bda197 100644 --- a/src/osp/drawing_gl/FullscreenTriShader.h +++ b/src/osp/drawing_gl/FullscreenTriShader.h @@ -34,8 +34,8 @@ class FullscreenTriShader : public Magnum::GL::AbstractShaderProgram { public: // Vertex attribs - typedef Magnum::GL::Attribute<0, Magnum::Vector2> Position; - typedef Magnum::GL::Attribute<1, Magnum::Vector2> TextureCoordinates; + using Position = Magnum::GL::Attribute<0, Magnum::Vector2>; + using TextureCoordinates = Magnum::GL::Attribute<1, Magnum::Vector2>; // Outputs enum class EOutputs : Magnum::UnsignedInt @@ -54,6 +54,7 @@ class FullscreenTriShader : public Magnum::GL::AbstractShaderProgram * @param texture - The texture to display */ void display_texure(Magnum::GL::Mesh& surface, Magnum::GL::Texture2D& texture); + private: // Uniforms enum class EUniformPos : Magnum::Int diff --git a/src/osp/drawing_gl/rendergl.h b/src/osp/drawing_gl/rendergl.h index d42969eb..5b1ea4dd 100644 --- a/src/osp/drawing_gl/rendergl.h +++ b/src/osp/drawing_gl/rendergl.h @@ -38,6 +38,8 @@ #include +#include + namespace osp::draw { @@ -111,7 +113,6 @@ struct ACtxSceneRenderGL */ class SysRenderGL { - public: /** @@ -174,10 +175,10 @@ class SysRenderGL MeshGlEntStorage_t& rCmpMeshGl, RenderGL& rRenderGl); - template + template SENT_T> static void sync_drawent_mesh( - ITA_T const& first, - ITB_T const& last, + IT_T const& first, + SENT_T const& last, KeyedVec const& cmpMeshIds, IdMap_t const& meshToRes, MeshGlEntStorage_t& rCmpMeshGl, @@ -205,10 +206,10 @@ class SysRenderGL TexGlEntStorage_t& rCmpTexGl, RenderGL& rRenderGl); - template + template SENT_T> static void sync_drawent_texture( - ITA_T const& first, - ITB_T const& last, + IT_T const& first, + SENT_T const& last, KeyedVec const& cmpTexIds, IdMap_t const& texToRes, TexGlEntStorage_t& rCmpTexGl, diff --git a/src/osp/link/machines.h b/src/osp/link/machines.h index c2a744a0..e2e3c2c3 100644 --- a/src/osp/link/machines.h +++ b/src/osp/link/machines.h @@ -35,20 +35,23 @@ #include #include +#include + +#include namespace osp::link { -using MachTypeId = uint16_t; -using MachAnyId = uint32_t; -using MachLocalId = uint32_t; +using MachTypeId = std::uint16_t; +using MachAnyId = std::uint32_t; +using MachLocalId = std::uint32_t; -using NodeTypeId = uint16_t; -using NodeId = uint32_t; +using NodeTypeId = std::uint16_t; +using NodeId = std::uint32_t; -using PortId = uint16_t; -using JunctionId = uint16_t; -using JuncCustom = uint16_t; +using PortId = std::uint16_t; +using JunctionId = std::uint16_t; +using JuncCustom = std::uint16_t; using MachTypeReg_t = GlobalIdReg; using NodeTypeReg_t = GlobalIdReg; @@ -128,7 +131,7 @@ struct PortEntry JuncCustom custom; }; -inline NodeId connected_node(lgrn::Span portSpan, PortId port) noexcept +inline NodeId connected_node(std::span portSpan, PortId port) noexcept { return (portSpan.size() > port) ? portSpan[port] : lgrn::id_null(); } @@ -146,5 +149,4 @@ void copy_nodes( Machines &rDstMach, ArrayView remapNodeOut); - } // namespace osp::wire diff --git a/src/osp/link/signal.h b/src/osp/link/signal.h index cb4e0fd5..c27b2298 100644 --- a/src/osp/link/signal.h +++ b/src/osp/link/signal.h @@ -51,6 +51,7 @@ struct UpdateNodes } }; +// TODO: convert to std::ranges::input_range template bool update_signal_nodes( RANGE_T const& toUpdate, @@ -62,13 +63,13 @@ bool update_signal_nodes( { bool somethingNotified = false; - for (uint32_t const node : toUpdate) + for (auto const node : toUpdate) { // Apply node value changes currentValues[node] = newValues[node]; // Notify connected inputs - for (Junction junc : nodeToMach[node]) + for (Junction const& junc : nodeToMach[node]) { if (junc.custom == gc_sigIn) { diff --git a/src/osp/tasks/builder.h b/src/osp/tasks/builder.h index 36104091..86df047d 100644 --- a/src/osp/tasks/builder.h +++ b/src/osp/tasks/builder.h @@ -30,9 +30,11 @@ #include #include +#include +#include + #include #include -#include namespace osp { @@ -103,9 +105,9 @@ struct TaskBuilderBase // RELEASE AND ISN'T CAUGHT BY ASAN WTF??? (on gcc 11) alignas(TGT_STRUCT_T) std::array bytes; - TGT_STRUCT_T *pOut = new(bytes.data()) TGT_STRUCT_T; + TGT_STRUCT_T *pOut = std::construct_at(reinterpret_cast(bytes.data())); - for (std::size_t i = 0; i < count; ++i) + for (std::size_t const i : std::views::iota(0u, count)) { PipelineId const pl = pipelinesOut[i]; unsigned char *pDefBytes = bytes.data() + sizeof(PipelineDefBlank_t)*i; @@ -157,10 +159,10 @@ struct TaskRefBase constexpr Tasks & tasks() noexcept { return m_rBuilder.m_rTasks; } - template + template TaskRef_t& add_edges(std::vector& rContainer, RANGE_T const& add) { - for (auto const [pipeline, stage] : add) + for (auto const& [pipeline, stage] : add) { rContainer.push_back({ .task = m_taskId, @@ -285,7 +287,7 @@ struct BasicBuilderTraits , m_rFuncs{rFuncs} { } Builder(Builder const& copy) = delete; - Builder(Builder && move) = default; + Builder(Builder && move) noexcept = default; Builder& operator=(Builder const& copy) = delete; diff --git a/src/osp/tasks/execute.h b/src/osp/tasks/execute.h index 4ea5c242..d3dcc5fa 100644 --- a/src/osp/tasks/execute.h +++ b/src/osp/tasks/execute.h @@ -92,7 +92,6 @@ struct LoopRequestRun PipelineTreePos_t treePos; }; - /** * @brief Fast plain-old-data log for ExecContext state changes */ diff --git a/src/osp/tasks/tasks.h b/src/osp/tasks/tasks.h index 2fd9a838..c0c85c91 100644 --- a/src/osp/tasks/tasks.h +++ b/src/osp/tasks/tasks.h @@ -32,29 +32,30 @@ #include -#include #include #include #include #include +#include + +#include -#define OSP_DECLARE_STAGE_NAMES(type, ...) \ - inline osp::ArrayView stage_names([[maybe_unused]] type _) noexcept \ - { \ - static auto const arr = std::initializer_list{__VA_ARGS__}; \ - return osp::arrayView(arr); \ +#define OSP_DECLARE_STAGE_NAMES(type, ...) \ + constexpr std::span stage_names([[maybe_unused]] type _) noexcept \ + { \ + return std::initializer_list{__VA_ARGS__}; \ } -#define OSP_DECLARE_STAGE_SCHEDULE(type, schedule_enum) \ - constexpr inline type stage_schedule([[maybe_unused]] type _) noexcept \ - { \ - return schedule_enum; \ +#define OSP_DECLARE_STAGE_SCHEDULE(type, schedule_enum) \ + constexpr type stage_schedule([[maybe_unused]] type _) noexcept \ + { \ + return schedule_enum; \ } -#define OSP_DECLARE_STAGE_NO_SCHEDULE(type) \ - constexpr inline type stage_schedule([[maybe_unused]] type _) noexcept \ - { \ - return lgrn::id_null(); \ +#define OSP_DECLARE_STAGE_NO_SCHEDULE(type) \ + constexpr type stage_schedule([[maybe_unused]] type _) noexcept \ + { \ + return lgrn::id_null(); \ } namespace osp @@ -64,10 +65,10 @@ constexpr std::size_t gc_maxStages = 16; using StageBits_t = std::bitset; -using TaskInt = uint32_t; -using PipelineInt = uint32_t; -using StageInt = uint8_t; -using SemaphoreInt = uint32_t; +using TaskInt = std::uint32_t; +using PipelineInt = std::uint32_t; +using StageInt = std::uint8_t; +using SemaphoreInt = std::uint32_t; enum class TaskId : TaskInt { }; enum class PipelineId : PipelineInt { }; @@ -81,10 +82,10 @@ struct PipelineInfo using stage_type_family_t = entt::family; using stage_type_t = stage_type_family_t::value_type; - static inline KeyedVec> sm_stageNames; + static inline KeyedVec> sm_stageNames; template - static inline constexpr void register_stage_enum() + static constexpr void register_stage_enum() { PipelineInfo::stage_type_t const type = PipelineInfo::stage_type_family_t::value; PipelineInfo::sm_stageNames[type] = stage_names(STAGE_ENUM_T{}); @@ -147,16 +148,16 @@ struct TaskEdges using PipelineTreePos_t = uint32_t; -enum class AnyStageId : uint32_t { }; +enum class AnyStageId : std::uint32_t { }; -enum class RunTaskId : uint32_t { }; -enum class RunStageId : uint32_t { }; +enum class RunTaskId : std::uint32_t { }; +enum class RunStageId : std::uint32_t { }; -enum class StageReqTaskId : uint32_t { }; -enum class ReverseStageReqTaskId : uint32_t { }; +enum class StageReqTaskId : std::uint32_t { }; +enum class ReverseStageReqTaskId : std::uint32_t { }; -enum class TaskReqStageId : uint32_t { }; -enum class ReverseTaskReqStageId : uint32_t { }; +enum class TaskReqStageId : std::uint32_t { }; +enum class ReverseTaskReqStageId : std::uint32_t { }; struct StageRequiresTask { @@ -292,12 +293,12 @@ inline VALUE_T id_from_count(KeyedVec const& vec, KEY_T const ke inline AnyStageId anystg_from(TaskGraph const& graph, PipelineId const pl, StageId stg) noexcept { - return AnyStageId(uint32_t(graph.pipelineToFirstAnystg[pl]) + uint32_t(stg)); + return AnyStageId(std::uint32_t(graph.pipelineToFirstAnystg[pl]) + std::uint32_t(stg)); } inline StageId stage_from(TaskGraph const& graph, PipelineId const pl, AnyStageId const stg) noexcept { - return StageId(uint32_t(stg) - uint32_t(graph.pipelineToFirstAnystg[pl])); + return StageId(std::uint32_t(stg) - std::uint32_t(graph.pipelineToFirstAnystg[pl])); } inline StageId stage_from(TaskGraph const& graph, AnyStageId const stg) noexcept diff --git a/src/osp/tasks/top_execute.cpp b/src/osp/tasks/top_execute.cpp index ebcc4e7b..4e3ea957 100644 --- a/src/osp/tasks/top_execute.cpp +++ b/src/osp/tasks/top_execute.cpp @@ -85,7 +85,7 @@ static void write_task_requirements(std::ostream &rStream, Tasks const& tasks, T { ExecPipeline const &reqPlData = exec.plData[req.reqPipeline]; PipelineInfo const& info = tasks.m_pipelineInfo[req.reqPipeline]; - auto const stageNames = ArrayView{PipelineInfo::sm_stageNames[info.stageType]}; + auto const stageNames = std::span{PipelineInfo::sm_stageNames[info.stageType]}; if (reqPlData.stage != req.reqStage) { @@ -147,7 +147,7 @@ std::ostream& operator<<(std::ostream& rStream, TopExecWriteState const& write) if (info.stageType != lgrn::id_null()) { - auto const stageNames = ArrayView{PipelineInfo::sm_stageNames[info.stageType]}; + auto const stageNames = std::span{PipelineInfo::sm_stageNames[info.stageType]}; for (int stage = 0; stage < std::min(stageNames.size(), stageCount); ++stage) { @@ -217,7 +217,7 @@ std::ostream& operator<<(std::ostream& rStream, TopExecWriteLog const& write) if (stg != lgrn::id_null()) { PipelineInfo const& info = tasks.m_pipelineInfo[pl]; - auto const stageNames = ArrayView{PipelineInfo::sm_stageNames[info.stageType]}; + auto const stageNames = std::span{PipelineInfo::sm_stageNames[info.stageType]}; return stageNames[std::size_t(stg)]; } else