Browse Source

Math: move STL-dependent doc snippets to a dedicated file.

Limiting the bloat spread as much as possible.
pull/638/head
Vladimír Vondruš 2 years ago
parent
commit
21cfae82fa
  1. 1
      doc/snippets/CMakeLists.txt
  2. 47
      doc/snippets/MagnumMath-stl.cpp
  3. 13
      doc/snippets/MagnumMath.cpp
  4. 2
      src/Magnum/Math/StrictWeakOrdering.h

1
doc/snippets/CMakeLists.txt

@ -41,6 +41,7 @@ set(snippets_Magnum_SRCS
MagnumAnimation.cpp MagnumAnimation.cpp
MagnumAnimation-custom.cpp MagnumAnimation-custom.cpp
MagnumMath.cpp MagnumMath.cpp
MagnumMath-stl.cpp
MagnumMathAlgorithms.cpp) MagnumMathAlgorithms.cpp)
if(CORRADE_TARGET_EMSCRIPTEN) if(CORRADE_TARGET_EMSCRIPTEN)
list(APPEND snippets_Magnum_SRCS platforms-html5.cpp) list(APPEND snippets_Magnum_SRCS platforms-html5.cpp)

47
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š <mosra@centrum.cz>
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 <map>
#include <set>
#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<Vector2, Math::StrictWeakOrdering> mySet;
std::map<Vector4, Int, Math::StrictWeakOrdering> myMap;
/* [StrictWeakOrdering] */
static_cast<void>(myMap);
static_cast<void>(mySet);
}
}

13
doc/snippets/MagnumMath.cpp

@ -23,9 +23,6 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <map>
#include <set>
#include "Magnum/Magnum.h" #include "Magnum/Magnum.h"
#include "Magnum/Math/Color.h" #include "Magnum/Math/Color.h"
#include "Magnum/Math/FunctionsBatch.h" #include "Magnum/Math/FunctionsBatch.h"
@ -37,7 +34,6 @@
#include "Magnum/Math/Frustum.h" #include "Magnum/Math/Frustum.h"
#include "Magnum/Math/Half.h" #include "Magnum/Math/Half.h"
#include "Magnum/Math/Range.h" #include "Magnum/Math/Range.h"
#include "Magnum/Math/StrictWeakOrdering.h"
#include "Magnum/Math/Swizzle.h" #include "Magnum/Math/Swizzle.h"
#include "Magnum/Math/Algorithms/GramSchmidt.h" #include "Magnum/Math/Algorithms/GramSchmidt.h"
@ -1233,15 +1229,6 @@ Float a = m[2][1];
static_cast<void>(a); static_cast<void>(a);
} }
{
/* [StrictWeakOrdering] */
std::set<Vector2, Math::StrictWeakOrdering> mySet;
std::map<Vector4, Int, Math::StrictWeakOrdering> myMap;
/* [StrictWeakOrdering] */
static_cast<void>(myMap);
static_cast<void>(mySet);
}
{ {
/* [gather] */ /* [gather] */
Vector4i original(-1, 2, 3, 4); Vector4i original(-1, 2, 3, 4);

2
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 mainly for interoperability with ordering containers from the C++ standard
library, like @ref std::map and @link std::set @endlink: 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 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. source for defails if you want to create an implementation for your own types.

Loading…
Cancel
Save