From 21cfae82fad35e90add1860593ee4bc69367308d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 11 Feb 2024 21:10:07 +0100 Subject: [PATCH] Math: move STL-dependent doc snippets to a dedicated file. Limiting the bloat spread as much as possible. --- doc/snippets/CMakeLists.txt | 1 + doc/snippets/MagnumMath-stl.cpp | 47 ++++++++++++++++++++++++++++ doc/snippets/MagnumMath.cpp | 13 -------- src/Magnum/Math/StrictWeakOrdering.h | 2 +- 4 files changed, 49 insertions(+), 14 deletions(-) create mode 100644 doc/snippets/MagnumMath-stl.cpp diff --git a/doc/snippets/CMakeLists.txt b/doc/snippets/CMakeLists.txt index ba1a42ea0..fa777cd8c 100644 --- a/doc/snippets/CMakeLists.txt +++ b/doc/snippets/CMakeLists.txt @@ -41,6 +41,7 @@ set(snippets_Magnum_SRCS MagnumAnimation.cpp MagnumAnimation-custom.cpp MagnumMath.cpp + MagnumMath-stl.cpp MagnumMathAlgorithms.cpp) if(CORRADE_TARGET_EMSCRIPTEN) list(APPEND snippets_Magnum_SRCS platforms-html5.cpp) diff --git a/doc/snippets/MagnumMath-stl.cpp b/doc/snippets/MagnumMath-stl.cpp new file mode 100644 index 000000000..2098ecb19 --- /dev/null +++ b/doc/snippets/MagnumMath-stl.cpp @@ -0,0 +1,47 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, + 2020, 2021, 2022, 2023 Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include +#include + +#include "Magnum/Math/StrictWeakOrdering.h" +#include "Magnum/Math/Vector4.h" + +#define DOXYGEN_ELLIPSIS(...) __VA_ARGS__ +#define DOXYGEN_IGNORE(...) __VA_ARGS__ + +using namespace Magnum; +using namespace Magnum::Math::Literals; + +int main() { +{ +/* [StrictWeakOrdering] */ +std::set mySet; +std::map myMap; +/* [StrictWeakOrdering] */ +static_cast(myMap); +static_cast(mySet); +} +} diff --git a/doc/snippets/MagnumMath.cpp b/doc/snippets/MagnumMath.cpp index 77bfe2f5d..da171dcc0 100644 --- a/doc/snippets/MagnumMath.cpp +++ b/doc/snippets/MagnumMath.cpp @@ -23,9 +23,6 @@ DEALINGS IN THE SOFTWARE. */ -#include -#include - #include "Magnum/Magnum.h" #include "Magnum/Math/Color.h" #include "Magnum/Math/FunctionsBatch.h" @@ -37,7 +34,6 @@ #include "Magnum/Math/Frustum.h" #include "Magnum/Math/Half.h" #include "Magnum/Math/Range.h" -#include "Magnum/Math/StrictWeakOrdering.h" #include "Magnum/Math/Swizzle.h" #include "Magnum/Math/Algorithms/GramSchmidt.h" @@ -1233,15 +1229,6 @@ Float a = m[2][1]; static_cast(a); } -{ -/* [StrictWeakOrdering] */ -std::set mySet; -std::map myMap; -/* [StrictWeakOrdering] */ -static_cast(myMap); -static_cast(mySet); -} - { /* [gather] */ Vector4i original(-1, 2, 3, 4); diff --git a/src/Magnum/Math/StrictWeakOrdering.h b/src/Magnum/Math/StrictWeakOrdering.h index ce94fcf8a..9a3258289 100644 --- a/src/Magnum/Math/StrictWeakOrdering.h +++ b/src/Magnum/Math/StrictWeakOrdering.h @@ -50,7 +50,7 @@ set. With it an ordering can be achieved between the elements. This is useful mainly for interoperability with ordering containers from the C++ standard library, like @ref std::map and @link std::set @endlink: -@snippet MagnumMath.cpp StrictWeakOrdering +@snippet MagnumMath-stl.cpp StrictWeakOrdering The implementation is done for all types in the @ref Math library, check the source for defails if you want to create an implementation for your own types.