From 2620eca9ae9641a3b072ac69b8fcd81dac1c0d17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 30 Dec 2022 22:05:45 +0100 Subject: [PATCH] GL: drop another std::pair occurence from the internals. Hm, and here I used the "capability" of std::pair that allowed it to store references. I don't even want to know what all was involved to support that, Containers::Reference is much easier to reason about. --- src/Magnum/GL/Context.cpp | 7 ++++--- src/Magnum/GL/Implementation/State.cpp | 3 ++- src/Magnum/GL/Implementation/State.h | 3 +-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Magnum/GL/Context.cpp b/src/Magnum/GL/Context.cpp index 73bb860e8..b2542d3ee 100644 --- a/src/Magnum/GL/Context.cpp +++ b/src/Magnum/GL/Context.cpp @@ -28,6 +28,7 @@ #include /* std::lower_bound() */ #include #include +#include #include #include #include @@ -985,9 +986,9 @@ bool Context::tryCreate(const Configuration& configuration) { Debug{output} << " " << extension.string(); } - std::pair state = Implementation::State::allocate(*this, output); - _stateData = std::move(state.first); - _state = &state.second; + Containers::Pair> state = Implementation::State::allocate(*this, output); + _stateData = std::move(state.first()); + _state = &*state.second(); /* Print a list of used workarounds */ if(!_driverWorkarounds.isEmpty()) { diff --git a/src/Magnum/GL/Implementation/State.cpp b/src/Magnum/GL/Implementation/State.cpp index 3e6b12d39..b4d9b6180 100644 --- a/src/Magnum/GL/Implementation/State.cpp +++ b/src/Magnum/GL/Implementation/State.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include "Magnum/GL/Context.h" @@ -49,7 +50,7 @@ namespace Magnum { namespace GL { namespace Implementation { -std::pair State::allocate(Context& context, std::ostream* const out) { +Containers::Pair> State::allocate(Context& context, std::ostream* const out) { /* TextureState needs to track state per texture / image binding, fetch how many of them is there and allocate here as well so we don't need to do another nested allocation */ diff --git a/src/Magnum/GL/Implementation/State.h b/src/Magnum/GL/Implementation/State.h index b9d4635a8..819f04224 100644 --- a/src/Magnum/GL/Implementation/State.h +++ b/src/Magnum/GL/Implementation/State.h @@ -26,7 +26,6 @@ */ #include -#include #include #include "Magnum/Magnum.h" @@ -53,7 +52,7 @@ struct TransformFeedbackState; struct State { /* Initializes context-based functionality together with all nested classes in a single allocation */ - static std::pair allocate(Context& context, std::ostream* out); + static Containers::Pair> allocate(Context& context, std::ostream* out); enum: GLuint { DisengagedBinding = ~0u };