├── .circleci └── config.yml ├── .editorconfig ├── .gitignore ├── COPYING ├── CorradeArray.h ├── CorradeArrayView.h ├── CorradeCpu.hpp ├── CorradeEnumSet.h ├── CorradeFunction.h ├── CorradeGrowableArray.h ├── CorradeOptional.h ├── CorradePair.h ├── CorradePointer.h ├── CorradeReference.h ├── CorradeScopeGuard.h ├── CorradeStlForwardArray.h ├── CorradeStlForwardString.h ├── CorradeStlForwardTuple.h ├── CorradeStlForwardVector.h ├── CorradeStlMath.h ├── CorradeStridedArrayView.h ├── CorradeString.hpp ├── CorradeTriple.h ├── MagnumMath.hpp ├── MagnumMathBatch.hpp ├── MagnumMeshTools.hpp ├── README.md ├── package ├── ci │ └── circleci.yml └── generate-loc.sh └── test ├── CorradeArray.cpp ├── CorradeArrayView.cpp ├── CorradeCpu.cpp ├── CorradeEnumSet.cpp ├── CorradeFunction.cpp ├── CorradeGrowableArray.cpp ├── CorradeOptional.cpp ├── CorradePair.cpp ├── CorradePointer.cpp ├── CorradeReference.cpp ├── CorradeScopeGuard.cpp ├── CorradeStlForwardArray.cpp ├── CorradeStlForwardString.cpp ├── CorradeStlForwardTuple.cpp ├── CorradeStlForwardVector.cpp ├── CorradeStlMath.cpp ├── CorradeStridedArrayView.cpp ├── CorradeString.cpp ├── CorradeTriple.cpp ├── MagnumMath.cpp ├── MagnumMathBatch.cpp └── MagnumMeshTools.cpp /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | ../package/ci/circleci.yml -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | charset = utf-8 3 | indent_style = space 4 | indent_size = 4 5 | trim_trailing_whitespace = true 6 | insert_final_newline = true 7 | 8 | [*.yml] 9 | indent_style = space 10 | indent_size = 2 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | test/a.out 2 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2 | 2020, 2021, 2022, 2023, 2024, 2025 3 | Vladimír Vondruš and contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a 6 | copy of this software and associated documentation files (the "Software"), 7 | to deal in the Software without restriction, including without limitation 8 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | and/or sell copies of the Software, and to permit persons to whom the 10 | Software is furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included 13 | in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /CorradeEnumSet.h: -------------------------------------------------------------------------------- 1 | /* 2 | Corrade::Containers::EnumSet 3 | — a type-safe set of bits 4 | 5 | https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1EnumSet.html 6 | 7 | This is a single-header library generated from the Corrade project. With 8 | the goal being easy integration, it's deliberately free of all comments 9 | to keep the file size small. More info, detailed changelogs and docs here: 10 | 11 | - Project homepage — https://magnum.graphics/corrade/ 12 | - Documentation — https://doc.magnum.graphics/corrade/ 13 | - GitHub project page — https://github.com/mosra/corrade 14 | - GitHub Singles repository — https://github.com/mosra/magnum-singles 15 | 16 | v2020.06-1890-g77f9f (2025-04-11) 17 | - Cleanup and unification of SFINAE code, no functional change 18 | v2020.06-1506-g43e1c (2023-09-13) 19 | - Preventing a conflict with the EnumSet declaration in Corrade's 20 | Containers.h due to default template arguments being used in both 21 | v2020.06-1454-gfc3b7 (2023-08-27) 22 | - It's now possible to construct the EnumSet directly from the underlying 23 | enum's type instead of having to cast to the enum type first 24 | - Removed unnecessary function calls for improved debug performace 25 | v2020.06-1075-gdd71 (2022-10-13) 26 | - Initial release 27 | 28 | Generated from Corrade v2020.06-1890-g77f9f (2025-04-11), 269 / 1703 LoC 29 | */ 30 | 31 | /* 32 | This file is part of Corrade. 33 | 34 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 35 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 36 | Vladimír Vondruš 37 | 38 | Permission is hereby granted, free of charge, to any person obtaining a 39 | copy of this software and associated documentation files (the "Software"), 40 | to deal in the Software without restriction, including without limitation 41 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 42 | and/or sell copies of the Software, and to permit persons to whom the 43 | Software is furnished to do so, subject to the following conditions: 44 | 45 | The above copyright notice and this permission notice shall be included 46 | in all copies or substantial portions of the Software. 47 | 48 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 49 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 50 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 51 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 52 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 53 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 54 | DEALINGS IN THE SOFTWARE. 55 | */ 56 | 57 | #include 58 | 59 | #ifndef CorradeEnumSet_h 60 | #define CorradeEnumSet_h 61 | namespace Corrade { namespace Containers { 62 | 63 | #ifndef Corrade_Containers_Containers_h 64 | template::type fullValue = typename std::underlying_type::type(~0)> class EnumSet; 65 | #endif 66 | 67 | }} 68 | #endif 69 | #ifndef Corrade_Tags_h 70 | #define Corrade_Tags_h 71 | 72 | namespace Corrade { 73 | 74 | struct DefaultInitT { 75 | struct Init {}; 76 | constexpr explicit DefaultInitT(Init) {} 77 | }; 78 | 79 | struct ValueInitT { 80 | struct Init {}; 81 | constexpr explicit ValueInitT(Init) {} 82 | }; 83 | 84 | struct NoInitT { 85 | struct Init {}; 86 | constexpr explicit NoInitT(Init) {} 87 | }; 88 | 89 | struct NoCreateT { 90 | struct Init {}; 91 | constexpr explicit NoCreateT(Init) {} 92 | }; 93 | 94 | struct DirectInitT { 95 | struct Init {}; 96 | constexpr explicit DirectInitT(Init) {} 97 | }; 98 | 99 | struct InPlaceInitT { 100 | struct Init {}; 101 | constexpr explicit InPlaceInitT(Init) {} 102 | }; 103 | 104 | constexpr DefaultInitT DefaultInit{DefaultInitT::Init{}}; 105 | 106 | constexpr ValueInitT ValueInit{ValueInitT::Init{}}; 107 | 108 | constexpr NoInitT NoInit{NoInitT::Init{}}; 109 | 110 | constexpr NoCreateT NoCreate{NoCreateT::Init{}}; 111 | 112 | constexpr DirectInitT DirectInit{DirectInitT::Init{}}; 113 | 114 | constexpr InPlaceInitT InPlaceInit{InPlaceInitT::Init{}}; 115 | 116 | } 117 | 118 | #endif 119 | #ifndef Corrade_Containers_EnumSet_h 120 | #define Corrade_Containers_EnumSet_h 121 | 122 | namespace Corrade { namespace Containers { 123 | 124 | template::type fullValue> 125 | class EnumSet { 126 | static_assert(std::is_enum::value, "EnumSet type must be a strongly typed enum"); 127 | 128 | public: 129 | typedef T Type; 130 | 131 | typedef typename std::underlying_type::type UnderlyingType; 132 | 133 | enum: UnderlyingType { 134 | FullValue = fullValue 135 | }; 136 | 137 | constexpr /*implicit*/ EnumSet() noexcept: _value{} {} 138 | 139 | constexpr /*implicit*/ EnumSet(T value) noexcept: 140 | _value(static_cast(value)) {} 141 | 142 | constexpr explicit EnumSet(UnderlyingType value) noexcept: _value{value} {} 143 | 144 | explicit EnumSet(Corrade::NoInitT) {} 145 | 146 | constexpr bool operator==(EnumSet other) const { 147 | return _value == other._value; 148 | } 149 | 150 | constexpr bool operator!=(EnumSet other) const { 151 | return _value != other._value; 152 | } 153 | 154 | constexpr bool operator>=(EnumSet other) const { 155 | return (_value & other._value) == other._value; 156 | } 157 | 158 | constexpr bool operator<=(EnumSet other) const { 159 | return (_value & other._value) == _value; 160 | } 161 | 162 | constexpr EnumSet operator|(EnumSet other) const { 163 | return EnumSet(_value | other._value); 164 | } 165 | 166 | EnumSet& operator|=(EnumSet other) { 167 | _value |= other._value; 168 | return *this; 169 | } 170 | 171 | constexpr EnumSet operator&(EnumSet other) const { 172 | return EnumSet(_value & other._value); 173 | } 174 | 175 | EnumSet& operator&=(EnumSet other) { 176 | _value &= other._value; 177 | return *this; 178 | } 179 | 180 | constexpr EnumSet operator^(EnumSet other) const { 181 | return EnumSet(_value ^ other._value); 182 | } 183 | 184 | EnumSet& operator^=(EnumSet other) { 185 | _value ^= other._value; 186 | return *this; 187 | } 188 | 189 | constexpr EnumSet operator~() const { 190 | return EnumSet(fullValue & ~_value); 191 | } 192 | 193 | constexpr explicit operator bool() const { 194 | return _value != 0; 195 | } 196 | 197 | constexpr explicit operator UnderlyingType() const { 198 | return _value; 199 | } 200 | 201 | private: 202 | UnderlyingType _value; 203 | }; 204 | 205 | template::value>::type 207 | > constexpr typename std::underlying_type::type enumCastUnderlyingType(T value) { 208 | return typename std::underlying_type::type(value); 209 | } 210 | 211 | template::type fullValue> constexpr typename std::underlying_type::type enumCastUnderlyingType(EnumSet value) { 212 | return typename std::underlying_type::type(value); 213 | } 214 | 215 | #define CORRADE_ENUMSET_OPERATORS(class) \ 216 | constexpr bool operator==(class::Type a, class b) { \ 217 | return class(a) == b; \ 218 | } \ 219 | constexpr bool operator!=(class::Type a, class b) { \ 220 | return class(a) != b; \ 221 | } \ 222 | constexpr bool operator>=(class::Type a, class b) { \ 223 | return class(a) >= b; \ 224 | } \ 225 | constexpr bool operator<=(class::Type a, class b) { \ 226 | return class(a) <= b; \ 227 | } \ 228 | constexpr class operator|(class::Type a, class b) { \ 229 | return b | a; \ 230 | } \ 231 | constexpr class operator&(class::Type a, class b) { \ 232 | return b & a; \ 233 | } \ 234 | constexpr class operator^(class::Type a, class b) { \ 235 | return b ^ a; \ 236 | } \ 237 | constexpr class operator~(class::Type a) { \ 238 | return ~class(a); \ 239 | } 240 | 241 | #define CORRADE_ENUMSET_FRIEND_OPERATORS(class) \ 242 | friend constexpr bool operator==(typename class::Type a, class b) { \ 243 | return class(a) == b; \ 244 | } \ 245 | friend constexpr bool operator!=(typename class::Type a, class b) { \ 246 | return class(a) != b; \ 247 | } \ 248 | friend constexpr bool operator>=(typename class::Type a, class b) { \ 249 | return class(a) >= b; \ 250 | } \ 251 | friend constexpr bool operator<=(typename class::Type a, class b) { \ 252 | return class(a) <= b; \ 253 | } \ 254 | friend constexpr class operator|(typename class::Type a, class b) { \ 255 | return b | a; \ 256 | } \ 257 | friend constexpr class operator&(typename class::Type a, class b) { \ 258 | return b & a; \ 259 | } \ 260 | friend constexpr class operator^(typename class::Type a, class b) { \ 261 | return b ^ a; \ 262 | } \ 263 | friend constexpr class operator~(typename class::Type a) { \ 264 | return ~class(a); \ 265 | } 266 | 267 | }} 268 | 269 | #endif 270 | -------------------------------------------------------------------------------- /CorradeFunction.h: -------------------------------------------------------------------------------- 1 | /* 2 | Corrade::Containers::Function 3 | — a lightweight alternative to std::function 4 | 5 | https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1Function_3_01R_07Args_8_8_8_08_4.html 6 | 7 | This is a single-header library generated from the Corrade project. With 8 | the goal being easy integration, it's deliberately free of all comments 9 | to keep the file size small. More info, detailed changelogs and docs here: 10 | 11 | - Project homepage — https://magnum.graphics/corrade/ 12 | - Documentation — https://doc.magnum.graphics/corrade/ 13 | - GitHub project page — https://github.com/mosra/corrade 14 | - GitHub Singles repository — https://github.com/mosra/magnum-singles 15 | 16 | v2020.06-1846-gc4cdf (2025-01-07) 17 | - Fixed an issue where a Function used in a function argument would 18 | be ambiguous with an overload having Function of any number of 19 | arguments 20 | v2020.06-1631-g9001f (2024-05-17) 21 | - Initial release 22 | 23 | Generated from Corrade v2020.06-1846-gc4cdf (2025-01-07), 505 / 1907 LoC 24 | */ 25 | 26 | /* 27 | This file is part of Corrade. 28 | 29 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 30 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 31 | Vladimír Vondruš 32 | 33 | Permission is hereby granted, free of charge, to any person obtaining a 34 | copy of this software and associated documentation files (the "Software"), 35 | to deal in the Software without restriction, including without limitation 36 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 37 | and/or sell copies of the Software, and to permit persons to whom the 38 | Software is furnished to do so, subject to the following conditions: 39 | 40 | The above copyright notice and this permission notice shall be included 41 | in all copies or substantial portions of the Software. 42 | 43 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 44 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 45 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 46 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 47 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 48 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 49 | DEALINGS IN THE SOFTWARE. 50 | */ 51 | 52 | #include 53 | #include 54 | #include 55 | #if !defined(CORRADE_CONSTEXPR_ASSERT) && !defined(NDEBUG) 56 | #include 57 | #endif 58 | 59 | #ifdef __GNUC__ 60 | #define CORRADE_TARGET_GCC 61 | #endif 62 | #ifdef __clang__ 63 | #define CORRADE_TARGET_CLANG 64 | #endif 65 | #ifdef __MINGW32__ 66 | #define CORRADE_TARGET_MINGW 67 | #endif 68 | #if !defined(__x86_64) && !defined(_M_X64) && !defined(__aarch64__) && !defined(_M_ARM64) && !defined(__powerpc64__) && !defined(__wasm64__) 69 | #define CORRADE_TARGET_32BIT 70 | #endif 71 | 72 | #ifdef _MSC_VER 73 | #ifdef _MSVC_LANG 74 | #define CORRADE_CXX_STANDARD _MSVC_LANG 75 | #else 76 | #define CORRADE_CXX_STANDARD 201103L 77 | #endif 78 | #else 79 | #define CORRADE_CXX_STANDARD __cplusplus 80 | #endif 81 | #if CORRADE_CXX_STANDARD >= 202002 82 | #include 83 | #else 84 | #include 85 | #endif 86 | #ifdef _LIBCPP_VERSION 87 | #define CORRADE_TARGET_LIBCXX 88 | #elif defined(_CPPLIB_VER) 89 | #define CORRADE_TARGET_DINKUMWARE 90 | #elif defined(__GLIBCXX__) 91 | #define CORRADE_TARGET_LIBSTDCXX 92 | #elif defined(__has_include) 93 | #if __has_include() 94 | #include 95 | #ifdef __GLIBCXX__ 96 | #define CORRADE_TARGET_LIBSTDCXX 97 | #endif 98 | #endif 99 | #elif defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5 100 | #define CORRADE_TARGET_LIBSTDCXX 101 | #else 102 | #endif 103 | 104 | #if defined(CORRADE_TARGET_LIBSTDCXX) && __GNUC__ < 5 && _GLIBCXX_RELEASE < 7 105 | #define CORRADE_NO_STD_IS_TRIVIALLY_TRAITS 106 | #endif 107 | 108 | #if defined(_MSC_VER) && _MSC_VER < 1910 109 | #define CORRADE_MSVC2015_COMPATIBILITY 110 | #endif 111 | #if defined(_MSC_VER) && _MSC_VER < 1920 112 | #define CORRADE_MSVC2017_COMPATIBILITY 113 | #endif 114 | 115 | #ifdef _WIN32 116 | #define CORRADE_TARGET_WINDOWS 117 | #endif 118 | 119 | #ifndef Corrade_Utility_Move_h 120 | #define Corrade_Utility_Move_h 121 | 122 | #ifdef CORRADE_MSVC2015_COMPATIBILITY 123 | #include 124 | #endif 125 | 126 | namespace Corrade { namespace Utility { 127 | 128 | template constexpr T&& forward(typename std::remove_reference::type& t) noexcept { 129 | return static_cast(t); 130 | } 131 | 132 | template constexpr T&& forward(typename std::remove_reference::type&& t) noexcept { 133 | static_assert(!std::is_lvalue_reference::value, "T can't be a lvalue reference"); 134 | return static_cast(t); 135 | } 136 | 137 | template constexpr typename std::remove_reference::type&& move(T&& t) noexcept { 138 | return static_cast::type&&>(t); 139 | } 140 | 141 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 142 | template void swap(T& a, typename std::common_type::type& b) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_move_assignable::value) { 143 | T tmp = static_cast(a); 144 | a = static_cast(b); 145 | b = static_cast(tmp); 146 | } 147 | #else 148 | using std::swap; 149 | #endif 150 | 151 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 152 | template void swap(T(&a)[size], typename std::common_type::type b) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_move_assignable::value) { 153 | for(std::size_t i = 0; i != size; ++i) { 154 | T tmp = static_cast(a[i]); 155 | a[i] = static_cast(b[i]); 156 | b[i] = static_cast(tmp); 157 | } 158 | } 159 | #endif 160 | 161 | }} 162 | 163 | #endif 164 | #ifndef CORRADE_CONSTEXPR_ASSERT 165 | #ifdef NDEBUG 166 | #define CORRADE_CONSTEXPR_ASSERT(condition, message) static_cast(0) 167 | #else 168 | #define CORRADE_CONSTEXPR_ASSERT(condition, message) \ 169 | static_cast((condition) ? 0 : ([&]() { \ 170 | assert(!#condition); \ 171 | }(), 0)) 172 | #endif 173 | #endif 174 | #ifndef CORRADE_CONSTEXPR_DEBUG_ASSERT 175 | #define CORRADE_CONSTEXPR_DEBUG_ASSERT(condition, message) \ 176 | CORRADE_CONSTEXPR_ASSERT(condition, message) 177 | #endif 178 | #ifndef Corrade_Containers_Function_h 179 | #define Corrade_Containers_Function_h 180 | 181 | namespace Corrade { namespace Containers { 182 | 183 | struct NoAllocateInitT { 184 | struct Init {}; 185 | constexpr explicit NoAllocateInitT(Init) {} 186 | }; 187 | 188 | constexpr NoAllocateInitT NoAllocateInit{NoAllocateInitT::Init{}}; 189 | 190 | namespace Implementation { 191 | 192 | enum: std::size_t { FunctionPointerSize = 193 | #if !defined(CORRADE_TARGET_WINDOWS) || defined(CORRADE_TARGET_MINGW) 194 | 2*sizeof(void*)/sizeof(std::size_t) 195 | #else 196 | #ifdef CORRADE_TARGET_32BIT 197 | 12/sizeof(std::size_t) 198 | #else 199 | 16/sizeof(std::size_t) 200 | #endif 201 | #endif 202 | }; 203 | 204 | } 205 | 206 | class FunctionData { 207 | public: 208 | /*implicit*/ FunctionData(std::nullptr_t = nullptr) noexcept: _storage{}, _call{nullptr} {} 209 | 210 | FunctionData(const FunctionData&) = delete; 211 | 212 | FunctionData(FunctionData&&) noexcept; 213 | 214 | ~FunctionData(); 215 | 216 | FunctionData& operator=(const FunctionData&) = delete; 217 | 218 | FunctionData& operator=(FunctionData&&) noexcept; 219 | 220 | explicit operator bool() const { 221 | return _call || _storage.functor.call; 222 | } 223 | 224 | bool isAllocated() const { return !_call && _storage.functor.call; } 225 | 226 | private: 227 | template friend class Function; 228 | 229 | union Storage { 230 | char data[Implementation::FunctionPointerSize*sizeof(std::size_t) + sizeof(void*)]; 231 | 232 | void(*function)(); 233 | 234 | struct { 235 | char data[Implementation::FunctionPointerSize*sizeof(std::size_t)]; 236 | void* instance; 237 | } member; 238 | 239 | struct { 240 | void* data; 241 | void(*free)(Storage&); 242 | void(*call)(); 243 | } functor; 244 | }; 245 | 246 | constexpr explicit FunctionData(const Storage& storage, void(*call)()): 247 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 248 | _storage(storage), 249 | #else 250 | _storage{storage}, 251 | #endif 252 | _call{call} {} 253 | 254 | Storage _storage; 255 | void(*_call)(); 256 | }; 257 | 258 | namespace Implementation { 259 | 260 | template struct IsFunctor; 261 | template struct IsFunctor { 262 | enum: bool { value = false }; 263 | }; 264 | template struct FunctorSignature; 265 | template struct FunctorSignature { 266 | static void match(R(Class::*)(Args...)) {} 267 | static void match(R(Class::*)(Args...) &) {} 268 | static void match(R(Class::*)(Args...) const) {} 269 | static void match(R(Class::*)(Args...) const &) {} 270 | }; 271 | template struct IsFunctor::match(&T::operator()))> { 272 | enum: bool { value = !std::is_convertible::value }; 273 | }; 274 | 275 | } 276 | 277 | template class Function; 278 | 279 | template class Function: public FunctionData { 280 | public: 281 | typedef R(Type)(Args...); 282 | 283 | /*implicit*/ Function(std::nullptr_t = nullptr) noexcept: FunctionData{nullptr} {} 284 | 285 | /*implicit*/ Function(R(*f)(Args...)) noexcept; 286 | 287 | template /*implicit*/ Function(Instance& instance, R(Class::*f)(Args...)) noexcept; 288 | template /*implicit*/ Function(Instance& instance, R(Class::*f)(Args...) &) noexcept; 289 | template /*implicit*/ Function(Instance& instance, R(Class::*f)(Args...) const) noexcept; 290 | template /*implicit*/ Function(Instance& instance, R(Class::*f)(Args...) const &) noexcept; 291 | 292 | template /*implicit*/ Function(Instance&, std::nullptr_t) noexcept: Function{nullptr} {} 293 | 294 | template::type, R(*)(Args...)>::value || Implementation::IsFunctor::type, R(Args...)>::value, int>::type = 0 296 | > /*implicit*/ Function(F&& f) noexcept(sizeof(typename std::decay::type) <= sizeof(Storage) && 297 | #ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS 298 | std::is_trivially_copyable::type>::value 299 | #else 300 | __has_trivial_copy(typename std::decay::type) && __has_trivial_destructor(typename std::decay::type) 301 | #endif 302 | ): Function{nullptr, Utility::forward(f)} {} 303 | 304 | template::type, R(Args...)>::value, int>::type = 0 306 | > explicit Function(NoAllocateInitT, F&& f) noexcept; 307 | 308 | R operator()(Args... args); 309 | 310 | private: 311 | template::type, R(*)(Args...)>::value, int>::type = 0> explicit Function(std::nullptr_t, F&& f) noexcept: Function{static_cast(f)} {} 312 | 313 | template::type, R(*)(Args...)>::value && sizeof(typename std::decay::type) <= sizeof(Storage) && 314 | #ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS 315 | std::is_trivially_copyable::type>::value 316 | #else 317 | __has_trivial_copy(typename std::decay::type) && __has_trivial_destructor(typename std::decay::type) 318 | #endif 319 | , int>::type = 0> explicit Function(std::nullptr_t, F&& f) noexcept: 320 | Function{NoAllocateInit, f} {} 321 | 322 | template::type, R(*)(Args...)>::value && 325 | #endif 326 | (sizeof(typename std::decay::type) > sizeof(Storage) || 327 | #ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS 328 | !std::is_trivially_copyable::type>::value 329 | #else 330 | !__has_trivial_copy(typename std::decay::type) || !__has_trivial_destructor(typename std::decay::type) 331 | #endif 332 | ), int>::type = 0> explicit Function(std::nullptr_t, F&& f); 333 | }; 334 | 335 | inline FunctionData::FunctionData(FunctionData&& other) noexcept: 336 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 337 | _storage(other._storage), 338 | #else 339 | _storage{other._storage}, 340 | #endif 341 | _call{other._call} 342 | { 343 | if(!_call && _storage.functor.call) 344 | other._storage.functor.call = nullptr; 345 | } 346 | 347 | inline FunctionData:: ~FunctionData() { 348 | if(!_call && _storage.functor.call) 349 | _storage.functor.free(_storage); 350 | } 351 | 352 | inline FunctionData& FunctionData::operator=(FunctionData&& other) noexcept { 353 | using Utility::swap; 354 | swap(other._storage, _storage); 355 | swap(other._call, _call); 356 | return *this; 357 | } 358 | 359 | template inline R Function::operator()(Args... args) { 360 | void(*const call)() = _call ? _call : _storage.functor.call; 361 | return CORRADE_CONSTEXPR_DEBUG_ASSERT(call, "Containers::Function: the function is null"), 362 | reinterpret_cast(call)(_storage, Utility::forward(args)...); 363 | } 364 | 365 | template Function::Function(R(*f)(Args...)) noexcept { 366 | _storage.function = reinterpret_cast(f); 367 | _call = !f ? nullptr : reinterpret_cast( 368 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 369 | + 370 | #else 371 | static_cast 372 | #endif 373 | ([](Storage& storage, Args... args) -> R { 374 | return reinterpret_cast(storage.function)(Utility::forward(args)...); 375 | })); 376 | } 377 | 378 | template template::type, R(Args...)>::value, int>::type> Function::Function(NoAllocateInitT, F&& f) noexcept { 379 | static_assert(sizeof(typename std::decay::type) <= sizeof(FunctionData::Storage) && 380 | #ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS 381 | std::is_trivially_copyable::type>::value 382 | #else 383 | __has_trivial_copy(typename std::decay::type) && __has_trivial_destructor(typename std::decay::type) 384 | #endif 385 | , "functor too large or non-trivial to be stored without allocation"); 386 | 387 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 388 | new(&_storage.data) typename std::decay::type(f); 389 | #else 390 | new(&_storage.data) typename std::decay::type{Utility::move(f)}; 391 | #endif 392 | _call = reinterpret_cast( 393 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 394 | + 395 | #else 396 | static_cast 397 | #endif 398 | ([](Storage& storage, Args... args) -> R { 399 | return reinterpret_cast(storage.data)(Utility::forward(args)...); 400 | })); 401 | } 402 | 403 | template template::type, R(*)(Args...)>::value && 406 | #endif 407 | (sizeof(typename std::decay::type) > sizeof(FunctionData::Storage) || 408 | #ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS 409 | !std::is_trivially_copyable::type>::value 410 | #else 411 | !__has_trivial_copy(typename std::decay::type) || !__has_trivial_destructor(typename std::decay::type) 412 | #endif 413 | ), int>::type> Function::Function(std::nullptr_t, F&& f) { 414 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 415 | reinterpret_cast::type*&>(_storage.functor.data) = new typename std::decay::type(Utility::forward(f)); 416 | #else 417 | reinterpret_cast::type*&>(_storage.functor.data) = new typename std::decay::type{Utility::forward(f)}; 418 | #endif 419 | _storage.functor.free = [](Storage& storage) { 420 | delete reinterpret_cast::type*>(storage.functor.data); 421 | }; 422 | _storage.functor.call = reinterpret_cast( 423 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 424 | + 425 | #else 426 | static_cast 427 | #endif 428 | ([](Storage& storage, Args... args) -> R { 429 | return (*reinterpret_cast::type*>(storage.functor.data))(Utility::forward(args)...); 430 | })); 431 | _call = nullptr; 432 | } 433 | 434 | template template Function::Function(Instance& instance, R(Class::*f)(Args...)) noexcept { 435 | static_assert(sizeof(f) <= sizeof(_storage.member.data), 436 | "size of member function pointer is incorrectly assumed to be smaller"); 437 | if(!f) return; 438 | 439 | _storage.member.instance = &instance; 440 | reinterpret_cast(_storage.member.data) = f; 441 | _call = reinterpret_cast( 442 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 443 | + 444 | #else 445 | static_cast 446 | #endif 447 | ([](Storage& storage, Args... args) -> R { 448 | return (static_cast(storage.member.instance)->*reinterpret_cast(storage.member.data))(Utility::forward(args)...); 449 | })); 450 | } 451 | template template Function::Function(Instance& instance, R(Class::*f)(Args...) &) noexcept { 452 | static_assert(sizeof(f) <= sizeof(_storage.member.data), 453 | "size of member function pointer is incorrectly assumed to be smaller"); 454 | if(!f) return; 455 | 456 | _storage.member.instance = &instance; 457 | reinterpret_cast(_storage.member.data) = f; 458 | _call = reinterpret_cast( 459 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 460 | + 461 | #else 462 | static_cast 463 | #endif 464 | ([](Storage& storage, Args... args) -> R { 465 | return (static_cast(storage.member.instance)->*reinterpret_cast(storage.member.data))(Utility::forward(args)...); 466 | })); 467 | } 468 | template template Function::Function(Instance& instance, R(Class::*f)(Args...) const) noexcept { 469 | static_assert(sizeof(f) <= sizeof(_storage.member.data), 470 | "size of member function pointer is incorrectly assumed to be smaller"); 471 | if(!f) return; 472 | 473 | _storage.member.instance = &instance; 474 | reinterpret_cast(_storage.member.data) = f; 475 | _call = reinterpret_cast( 476 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 477 | + 478 | #else 479 | static_cast 480 | #endif 481 | ([](Storage& storage, Args... args) -> R { 482 | return (static_cast(storage.member.instance)->*reinterpret_cast(storage.member.data))(Utility::forward(args)...); 483 | })); 484 | } 485 | template template Function::Function(Instance& instance, R(Class::*f)(Args...) const &) noexcept { 486 | static_assert(sizeof(f) <= sizeof(_storage.member.data), 487 | "size of member function pointer is incorrectly assumed to be smaller"); 488 | if(!f) return; 489 | 490 | _storage.member.instance = &instance; 491 | reinterpret_cast(_storage.member.data) = f; 492 | _call = reinterpret_cast( 493 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 494 | + 495 | #else 496 | static_cast 497 | #endif 498 | ([](Storage& storage, Args... args) -> R { 499 | return (static_cast(storage.member.instance)->*reinterpret_cast(storage.member.data))(Utility::forward(args)...); 500 | })); 501 | } 502 | 503 | }} 504 | 505 | #endif 506 | -------------------------------------------------------------------------------- /CorradeOptional.h: -------------------------------------------------------------------------------- 1 | /* 2 | Corrade::Containers::Optional 3 | — a lightweight alternative to std::optional 4 | 5 | https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1Optional.html 6 | 7 | This is a single-header library generated from the Corrade project. With 8 | the goal being easy integration, it's deliberately free of all comments 9 | to keep the file size small. More info, detailed changelogs and docs here: 10 | 11 | - Project homepage — https://magnum.graphics/corrade/ 12 | - Documentation — https://doc.magnum.graphics/corrade/ 13 | - GitHub project page — https://github.com/mosra/corrade 14 | - GitHub Singles repository — https://github.com/mosra/magnum-singles 15 | 16 | The STL compatibility bits are included as well --- opt-in by specifying 17 | `#define CORRADE_OPTIONAL_STL_COMPATIBILITY` before including the file. 18 | Including it multiple times with different macros defined works too. 19 | 20 | v2020.06-1846-gc4cdf (2025-01-07) 21 | - Expanded the uninitialized value warning workaround to all GCC versions 22 | v2020.06-1502-g147e (2023-09-11) 23 | - Fixes to the Utility::swap() helper to avoid ambiguity with std::swap() 24 | v2020.06-1454-gfc3b7 (2023-08-27) 25 | - The InPlaceInit tag is moved from Containers to the root namespace 26 | - The underlying type is exposed in a new Optional::Type typedef 27 | - Working around false-positive uninitialized value warnings in GCC 10+ 28 | - Further workarounds for various compiler-specific issues and standard 29 | defects when using {}-initialization for aggregate types 30 | - Removed dependency on , resulting in about ~600 preprocessed 31 | lines less 32 | v2020.06-0-g61d1b58c (2020-06-27) 33 | - Working around various compiler-specific issues and standard defects 34 | when using {}-initialization for aggregate types 35 | v2019.10-0-g162d6a7d (2019-10-24) 36 | - Minor simplifications in the internals 37 | v2019.01-107-g80d9f347 (2019-03-23) 38 | - Including only when needed 39 | v2018.10-232-ge927d7f3 (2019-01-28) 40 | - Ability to "take" a value out of a r-value optional using operator* 41 | - Opt-in compatibility with from C++17 42 | v2018.10-183-g4eb1adc0 (2019-01-23) 43 | - Initial release 44 | 45 | Generated from Corrade v2020.06-1846-gc4cdf (2025-01-07), 458 / 1863 LoC 46 | */ 47 | 48 | /* 49 | This file is part of Corrade. 50 | 51 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 52 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 53 | Vladimír Vondruš 54 | 55 | Permission is hereby granted, free of charge, to any person obtaining a 56 | copy of this software and associated documentation files (the "Software"), 57 | to deal in the Software without restriction, including without limitation 58 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 59 | and/or sell copies of the Software, and to permit persons to whom the 60 | Software is furnished to do so, subject to the following conditions: 61 | 62 | The above copyright notice and this permission notice shall be included 63 | in all copies or substantial portions of the Software. 64 | 65 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 66 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 67 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 68 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 69 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 70 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 71 | DEALINGS IN THE SOFTWARE. 72 | */ 73 | 74 | #include 75 | #include 76 | #if !defined(CORRADE_ASSERT) && !defined(NDEBUG) 77 | #include 78 | #endif 79 | 80 | #if defined(_MSC_VER) && _MSC_VER < 1910 81 | #define CORRADE_MSVC2015_COMPATIBILITY 82 | #endif 83 | #ifdef __GNUC__ 84 | #define CORRADE_TARGET_GCC 85 | #endif 86 | #ifdef __clang__ 87 | #define CORRADE_TARGET_CLANG 88 | #endif 89 | 90 | #ifndef Corrade_Tags_h 91 | #define Corrade_Tags_h 92 | 93 | namespace Corrade { 94 | 95 | struct DefaultInitT { 96 | struct Init {}; 97 | constexpr explicit DefaultInitT(Init) {} 98 | }; 99 | 100 | struct ValueInitT { 101 | struct Init {}; 102 | constexpr explicit ValueInitT(Init) {} 103 | }; 104 | 105 | struct NoInitT { 106 | struct Init {}; 107 | constexpr explicit NoInitT(Init) {} 108 | }; 109 | 110 | struct NoCreateT { 111 | struct Init {}; 112 | constexpr explicit NoCreateT(Init) {} 113 | }; 114 | 115 | struct DirectInitT { 116 | struct Init {}; 117 | constexpr explicit DirectInitT(Init) {} 118 | }; 119 | 120 | struct InPlaceInitT { 121 | struct Init {}; 122 | constexpr explicit InPlaceInitT(Init) {} 123 | }; 124 | 125 | constexpr DefaultInitT DefaultInit{DefaultInitT::Init{}}; 126 | 127 | constexpr ValueInitT ValueInit{ValueInitT::Init{}}; 128 | 129 | constexpr NoInitT NoInit{NoInitT::Init{}}; 130 | 131 | constexpr NoCreateT NoCreate{NoCreateT::Init{}}; 132 | 133 | constexpr DirectInitT DirectInit{DirectInitT::Init{}}; 134 | 135 | constexpr InPlaceInitT InPlaceInit{InPlaceInitT::Init{}}; 136 | 137 | } 138 | 139 | #endif 140 | #ifndef Corrade_Utility_Move_h 141 | #define Corrade_Utility_Move_h 142 | 143 | #ifdef CORRADE_MSVC2015_COMPATIBILITY 144 | #include 145 | #endif 146 | 147 | namespace Corrade { namespace Utility { 148 | 149 | template constexpr T&& forward(typename std::remove_reference::type& t) noexcept { 150 | return static_cast(t); 151 | } 152 | 153 | template constexpr T&& forward(typename std::remove_reference::type&& t) noexcept { 154 | static_assert(!std::is_lvalue_reference::value, "T can't be a lvalue reference"); 155 | return static_cast(t); 156 | } 157 | 158 | template constexpr typename std::remove_reference::type&& move(T&& t) noexcept { 159 | return static_cast::type&&>(t); 160 | } 161 | 162 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 163 | template void swap(T& a, typename std::common_type::type& b) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_move_assignable::value) { 164 | T tmp = static_cast(a); 165 | a = static_cast(b); 166 | b = static_cast(tmp); 167 | } 168 | #else 169 | using std::swap; 170 | #endif 171 | 172 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 173 | template void swap(T(&a)[size], typename std::common_type::type b) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_move_assignable::value) { 174 | for(std::size_t i = 0; i != size; ++i) { 175 | T tmp = static_cast(a[i]); 176 | a[i] = static_cast(b[i]); 177 | b[i] = static_cast(tmp); 178 | } 179 | } 180 | #endif 181 | 182 | }} 183 | 184 | #endif 185 | #ifndef Corrade_Containers_constructHelpers_h 186 | #define Corrade_Containers_constructHelpers_h 187 | 188 | namespace Corrade { namespace Containers { namespace Implementation { 189 | 190 | template inline void construct(T& value, First&& first, Next&& ...next) { 191 | new(&value) T{Utility::forward(first), Utility::forward(next)...}; 192 | } 193 | template inline void construct(T& value) { 194 | new(&value) T(); 195 | } 196 | 197 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 198 | template inline void construct(T& value, const T& b) { 199 | new(&value) T(b); 200 | } 201 | template inline void construct(T& value, T&& b) { 202 | new(&value) T(Utility::move(b)); 203 | } 204 | #endif 205 | 206 | }}} 207 | 208 | #endif 209 | #ifndef CORRADE_ASSERT 210 | #ifdef NDEBUG 211 | #define CORRADE_ASSERT(condition, message, returnValue) do {} while(false) 212 | #else 213 | #define CORRADE_ASSERT(condition, message, returnValue) assert(condition) 214 | #endif 215 | #endif 216 | #ifndef CORRADE_DEBUG_ASSERT 217 | #define CORRADE_DEBUG_ASSERT(condition, message, returnValue) \ 218 | CORRADE_ASSERT(condition, message, returnValue) 219 | #endif 220 | #ifndef Corrade_Containers_Optional_h 221 | #define Corrade_Containers_Optional_h 222 | 223 | namespace Corrade { namespace Containers { 224 | 225 | namespace Implementation { 226 | template struct OptionalConverter; 227 | } 228 | 229 | struct NullOptT { 230 | struct Init{}; 231 | constexpr explicit NullOptT(Init) {} 232 | }; 233 | 234 | constexpr NullOptT NullOpt{NullOptT::Init{}}; 235 | 236 | template class Optional { 237 | public: 238 | typedef T Type; 239 | 240 | /*implicit*/ Optional(NullOptT = NullOpt) noexcept: _set{false} {} 241 | 242 | /*implicit*/ Optional(const T& value) noexcept(std::is_nothrow_copy_constructible::value): _set{true} { 243 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 244 | Implementation::construct(_value, value); 245 | #else 246 | new(&_value) T{value}; 247 | #endif 248 | } 249 | 250 | /*implicit*/ Optional(T&& value) noexcept(std::is_nothrow_move_constructible::value): _set{true} { 251 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 252 | Implementation::construct(_value, Utility::move(value)); 253 | #else 254 | new(&_value) T{Utility::move(value)}; 255 | #endif 256 | } 257 | 258 | template /*implicit*/ Optional(Corrade::InPlaceInitT, Args&&... args) noexcept(std::is_nothrow_constructible::value): _set{true} { 259 | Implementation::construct(_value, Utility::forward(args)...); 260 | } 261 | 262 | template::from(std::declval()))> explicit Optional(const U& other) noexcept(std::is_nothrow_copy_constructible::value): Optional{Implementation::OptionalConverter::from(other)} {} 263 | 264 | template::from(std::declval()))> explicit Optional(U&& other) noexcept(std::is_nothrow_move_constructible::value): Optional{Implementation::OptionalConverter::from(Utility::move(other))} {} 265 | 266 | Optional(const Optional& other) noexcept(std::is_nothrow_copy_constructible::value); 267 | 268 | Optional(Optional&& other) noexcept(std::is_nothrow_move_constructible::value); 269 | 270 | Optional& operator=(const Optional& other) noexcept(std::is_nothrow_copy_assignable::value); 271 | 272 | Optional& operator=(Optional&& other) noexcept(std::is_nothrow_move_assignable::value); 273 | 274 | template::to(std::declval&>()))> explicit operator U() const & { 275 | return Implementation::OptionalConverter::to(*this); 276 | } 277 | 278 | template::to(std::declval&&>()))> explicit operator U() && { 279 | return Implementation::OptionalConverter::to(Utility::move(*this)); 280 | } 281 | 282 | Optional& operator=(NullOptT) noexcept; 283 | 284 | ~Optional() { if(_set) _value.~T(); } 285 | 286 | explicit operator bool() const { return _set; } 287 | 288 | bool operator==(const Optional& other) const { 289 | return (!_set && !other._set) || (_set && other._set && _value == other._value); 290 | } 291 | 292 | bool operator!=(const Optional& other) const { return !operator==(other); } 293 | 294 | bool operator==(NullOptT) const { return !_set; } 295 | 296 | bool operator!=(NullOptT) const { return _set; } 297 | 298 | bool operator==(const T& other) const { 299 | return _set ? _value == other : false; 300 | } 301 | 302 | bool operator!=(const T& other) const { return !operator==(other); } 303 | 304 | T* operator->() { 305 | CORRADE_DEBUG_ASSERT(_set, "Containers::Optional: the optional is empty", &_value); 306 | return &_value; 307 | } 308 | 309 | const T* operator->() const { 310 | CORRADE_DEBUG_ASSERT(_set, "Containers::Optional: the optional is empty", &_value); 311 | return &_value; 312 | } 313 | 314 | T& operator*() & { 315 | CORRADE_DEBUG_ASSERT(_set, "Containers::Optional: the optional is empty", _value); 316 | return _value; 317 | } 318 | 319 | T operator*() && { 320 | CORRADE_DEBUG_ASSERT(_set, "Containers::Optional: the optional is empty", Utility::move(_value)); 321 | return Utility::move(_value); 322 | } 323 | 324 | const T& operator*() const & { 325 | CORRADE_DEBUG_ASSERT(_set, "Containers::Optional: the optional is empty", _value); 326 | return _value; 327 | } 328 | 329 | template T& emplace(Args&&... args); 330 | 331 | private: 332 | union { 333 | T _value; 334 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __OPTIMIZE__ 335 | volatile char _gccStopSayingThisIsMaybeUninitialized[sizeof(T)]; 336 | #endif 337 | }; 338 | bool _set; 339 | }; 340 | 341 | template bool operator==(NullOptT, const Optional& b) { return b == NullOpt; } 342 | 343 | template bool operator!=(NullOptT, const Optional& b) { return b != NullOpt; } 344 | 345 | template bool operator==(const T& a, const Optional& b) { return b == a; } 346 | 347 | template bool operator!=(const T& a, const Optional& b) { return b != a; } 348 | 349 | namespace Implementation { 350 | template struct DeducedOptionalConverter { typedef T Type; }; 351 | } 352 | 353 | template inline 354 | Optional::type>::Type> 355 | optional(T&& value) { 356 | return Optional::type>{Utility::forward(value)}; 357 | } 358 | 359 | template inline Optional optional(Args&&... args) { 360 | return Optional{Corrade::InPlaceInit, Utility::forward(args)...}; 361 | } 362 | 363 | template inline auto optional(T&& other) -> decltype(Implementation::DeducedOptionalConverter::type>::from(Utility::forward(other))) { 364 | return Implementation::DeducedOptionalConverter::type>::from(Utility::forward(other)); 365 | } 366 | 367 | template Optional::Optional(const Optional& other) noexcept(std::is_nothrow_copy_constructible::value): _set(other._set) { 368 | if(_set) 369 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 370 | Implementation::construct(_value, other._value); 371 | #else 372 | new(&_value) T{other._value}; 373 | #endif 374 | } 375 | 376 | template Optional::Optional(Optional&& other) noexcept(std::is_nothrow_move_constructible::value): _set(other._set) { 377 | if(_set) 378 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 379 | Implementation::construct(_value, Utility::move(other._value)); 380 | #else 381 | new(&_value) T{Utility::move(other._value)}; 382 | #endif 383 | } 384 | 385 | template Optional& Optional::operator=(const Optional& other) noexcept(std::is_nothrow_copy_assignable::value) { 386 | if(_set) _value.~T(); 387 | if((_set = other._set)) 388 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 389 | Implementation::construct(_value, other._value); 390 | #else 391 | new(&_value) T{other._value}; 392 | #endif 393 | return *this; 394 | } 395 | 396 | template Optional& Optional::operator=(Optional&& other) noexcept(std::is_nothrow_move_assignable::value) { 397 | if(_set && other._set) { 398 | using Utility::swap; 399 | swap(other._value, _value); 400 | } else { 401 | if(_set) _value.~T(); 402 | if((_set = other._set)) 403 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 404 | Implementation::construct(_value, Utility::move(other._value)); 405 | #else 406 | new(&_value) T{Utility::move(other._value)}; 407 | #endif 408 | } 409 | return *this; 410 | } 411 | 412 | template Optional& Optional::operator=(NullOptT) noexcept { 413 | if(_set) _value.~T(); 414 | _set = false; 415 | return *this; 416 | } 417 | 418 | template template T& Optional::emplace(Args&&... args) { 419 | if(_set) _value.~T(); 420 | Implementation::construct(_value, Utility::forward(args)...); 421 | _set = true; 422 | return _value; 423 | } 424 | 425 | }} 426 | 427 | #endif 428 | #ifdef CORRADE_OPTIONAL_STL_COMPATIBILITY 429 | #include 430 | #ifndef Corrade_Containers_OptionalStl_h 431 | #define Corrade_Containers_OptionalStl_h 432 | 433 | namespace Corrade { namespace Containers { namespace Implementation { 434 | 435 | template struct OptionalConverter> { 436 | static Optional from(const std::optional& other) { 437 | return other ? Optional{*other} : Containers::NullOpt; 438 | } 439 | 440 | static Optional from(std::optional&& other) { 441 | return other ? Optional{*Utility::move(other)} : Containers::NullOpt; 442 | } 443 | 444 | static std::optional to(const Optional& other) { 445 | return other ? std::optional{*other} : std::nullopt; 446 | } 447 | 448 | static std::optional to(Optional&& other) { 449 | return other ? std::optional{*Utility::move(other)} : std::nullopt; 450 | } 451 | }; 452 | 453 | template struct DeducedOptionalConverter>: OptionalConverter> {}; 454 | 455 | }}} 456 | 457 | #endif 458 | #endif 459 | -------------------------------------------------------------------------------- /CorradePair.h: -------------------------------------------------------------------------------- 1 | /* 2 | Corrade::Containers::Pair 3 | — a lightweight alternative to std::pair 4 | 5 | https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1Pair.html 6 | 7 | This is a single-header library generated from the Corrade project. With 8 | the goal being easy integration, it's deliberately free of all comments 9 | to keep the file size small. More info, detailed changelogs and docs here: 10 | 11 | - Project homepage — https://magnum.graphics/corrade/ 12 | - Documentation — https://doc.magnum.graphics/corrade/ 13 | - GitHub project page — https://github.com/mosra/corrade 14 | - GitHub Singles repository — https://github.com/mosra/magnum-singles 15 | 16 | Structured bindings on C++17 are opt-in due to reliance on a potentially 17 | heavy STL header --- `#define CORRADE_STRUCTURED_BINDINGS` before including 18 | the file. The STL compatibility bits are included as well --- opt-in with 19 | `#define CORRADE_PAIR_STL_COMPATIBILITY` before including the file. 20 | Including it multiple times with different macros defined works too. 21 | 22 | v2020.06-1890-g77f9f (2025-04-11) 23 | - NoInit construction now works also with mixed trivial and class types 24 | - Cleanup and unification of SFINAE code 25 | v2020.06-1846-gc4cdf (2025-01-07) 26 | - Non-const C++17 structured bindings are now constexpr as well 27 | - Structured bindings of const types now work even w/o 28 | v2020.06-1687-g6b5f (2024-06-29) 29 | - Added explicit conversion constructors 30 | - Structured bindings on C++17 31 | v2020.06-1502-g147e (2023-09-11) 32 | - Fixes to the Utility::swap() helper to avoid ambiguity with std::swap() 33 | v2020.06-1454-gfc3b7 (2023-08-27) 34 | - Initial release 35 | 36 | Generated from Corrade v2020.06-1890-g77f9f (2025-04-11), 441 / 1748 LoC 37 | */ 38 | 39 | /* 40 | This file is part of Corrade. 41 | 42 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 43 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 44 | Vladimír Vondruš 45 | Copyright © 2022, 2023 Stanislaw Halik 46 | 47 | Permission is hereby granted, free of charge, to any person obtaining a 48 | copy of this software and associated documentation files (the "Software"), 49 | to deal in the Software without restriction, including without limitation 50 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 51 | and/or sell copies of the Software, and to permit persons to whom the 52 | Software is furnished to do so, subject to the following conditions: 53 | 54 | The above copyright notice and this permission notice shall be included 55 | in all copies or substantial portions of the Software. 56 | 57 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 58 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 59 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 60 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 61 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 62 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 63 | DEALINGS IN THE SOFTWARE. 64 | */ 65 | 66 | #include 67 | #include 68 | 69 | #if defined(_MSC_VER) && _MSC_VER < 1910 70 | #define CORRADE_MSVC2015_COMPATIBILITY 71 | #endif 72 | #ifdef __GNUC__ 73 | #define CORRADE_TARGET_GCC 74 | #endif 75 | #ifdef __clang__ 76 | #define CORRADE_TARGET_CLANG 77 | #endif 78 | #ifdef _MSC_VER 79 | #ifdef _MSVC_LANG 80 | #define CORRADE_CXX_STANDARD _MSVC_LANG 81 | #else 82 | #define CORRADE_CXX_STANDARD 201103L 83 | #endif 84 | #else 85 | #define CORRADE_CXX_STANDARD __cplusplus 86 | #endif 87 | 88 | #ifndef Corrade_Tags_h 89 | #define Corrade_Tags_h 90 | 91 | namespace Corrade { 92 | 93 | struct DefaultInitT { 94 | struct Init {}; 95 | constexpr explicit DefaultInitT(Init) {} 96 | }; 97 | 98 | struct ValueInitT { 99 | struct Init {}; 100 | constexpr explicit ValueInitT(Init) {} 101 | }; 102 | 103 | struct NoInitT { 104 | struct Init {}; 105 | constexpr explicit NoInitT(Init) {} 106 | }; 107 | 108 | struct NoCreateT { 109 | struct Init {}; 110 | constexpr explicit NoCreateT(Init) {} 111 | }; 112 | 113 | struct DirectInitT { 114 | struct Init {}; 115 | constexpr explicit DirectInitT(Init) {} 116 | }; 117 | 118 | struct InPlaceInitT { 119 | struct Init {}; 120 | constexpr explicit InPlaceInitT(Init) {} 121 | }; 122 | 123 | constexpr DefaultInitT DefaultInit{DefaultInitT::Init{}}; 124 | 125 | constexpr ValueInitT ValueInit{ValueInitT::Init{}}; 126 | 127 | constexpr NoInitT NoInit{NoInitT::Init{}}; 128 | 129 | constexpr NoCreateT NoCreate{NoCreateT::Init{}}; 130 | 131 | constexpr DirectInitT DirectInit{DirectInitT::Init{}}; 132 | 133 | constexpr InPlaceInitT InPlaceInit{InPlaceInitT::Init{}}; 134 | 135 | } 136 | 137 | #endif 138 | #if CORRADE_CXX_STANDARD >= 201402 && !defined(CORRADE_MSVC2015_COMPATIBILITY) 139 | #define CORRADE_CONSTEXPR14 constexpr 140 | #else 141 | #define CORRADE_CONSTEXPR14 142 | #endif 143 | #ifndef Corrade_Utility_Move_h 144 | #define Corrade_Utility_Move_h 145 | 146 | #ifdef CORRADE_MSVC2015_COMPATIBILITY 147 | #include 148 | #endif 149 | 150 | namespace Corrade { namespace Utility { 151 | 152 | template constexpr T&& forward(typename std::remove_reference::type& t) noexcept { 153 | return static_cast(t); 154 | } 155 | 156 | template constexpr T&& forward(typename std::remove_reference::type&& t) noexcept { 157 | static_assert(!std::is_lvalue_reference::value, "T can't be a lvalue reference"); 158 | return static_cast(t); 159 | } 160 | 161 | template constexpr typename std::remove_reference::type&& move(T&& t) noexcept { 162 | return static_cast::type&&>(t); 163 | } 164 | 165 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 166 | template void swap(T& a, typename std::common_type::type& b) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_move_assignable::value) { 167 | T tmp = static_cast(a); 168 | a = static_cast(b); 169 | b = static_cast(tmp); 170 | } 171 | #else 172 | using std::swap; 173 | #endif 174 | 175 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 176 | template void swap(T(&a)[size], typename std::common_type::type b) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_move_assignable::value) { 177 | for(std::size_t i = 0; i != size; ++i) { 178 | T tmp = static_cast(a[i]); 179 | a[i] = static_cast(b[i]); 180 | b[i] = static_cast(tmp); 181 | } 182 | } 183 | #endif 184 | 185 | }} 186 | 187 | #endif 188 | #ifndef Corrade_Containers_Pair_h 189 | #define Corrade_Containers_Pair_h 190 | 191 | namespace Corrade { namespace Containers { 192 | 193 | namespace Implementation { 194 | template struct PairConverter; 195 | } 196 | 197 | template class Pair { 198 | static_assert(!std::is_lvalue_reference::value && !std::is_lvalue_reference::value, "use a Reference to store a T& in a Pair"); 199 | 200 | public: 201 | typedef F FirstType; 202 | typedef S SecondType; 203 | 204 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 205 | constexpr 206 | #endif 207 | explicit Pair(Corrade::DefaultInitT) noexcept(std::is_nothrow_constructible::value && std::is_nothrow_constructible::value) {} 208 | 209 | constexpr explicit Pair(Corrade::ValueInitT) noexcept(std::is_nothrow_constructible::value && std::is_nothrow_constructible::value): 210 | _first(), _second() {} 211 | 212 | template::value && std::is_trivial::value && std::is_standard_layout::value && std::is_trivial::value, int>::type = 0> explicit Pair(Corrade::NoInitT) noexcept {} 213 | template::value && std::is_trivial::value && std::is_constructible::value, int>::type = 0> explicit Pair(Corrade::NoInitT) noexcept(std::is_nothrow_constructible::value): _second{Corrade::NoInit} {} 214 | template::value && std::is_standard_layout::value && std::is_trivial::value, int>::type = 0> explicit Pair(Corrade::NoInitT) noexcept(std::is_nothrow_constructible::value): _first{Corrade::NoInit} {} 215 | template::value && std::is_constructible::value, int>::type = 0> explicit Pair(Corrade::NoInitT) noexcept(std::is_nothrow_constructible::value && std::is_nothrow_constructible::value): _first{Corrade::NoInit}, _second{Corrade::NoInit} {} 216 | 217 | constexpr /*implicit*/ Pair() noexcept(std::is_nothrow_constructible::value && std::is_nothrow_constructible::value): 218 | #ifdef CORRADE_MSVC2015_COMPATIBILITY 219 | _first{}, _second{} 220 | #else 221 | Pair{Corrade::ValueInit} 222 | #endif 223 | {} 224 | 225 | constexpr /*implicit*/ Pair(const F& first, const S& second) noexcept(std::is_nothrow_copy_constructible::value && std::is_nothrow_copy_constructible::value): 226 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 227 | _first(first), _second(second) 228 | #else 229 | _first{first}, _second{second} 230 | #endif 231 | {} 232 | constexpr /*implicit*/ Pair(const F& first, S&& second) noexcept(std::is_nothrow_copy_constructible::value && std::is_nothrow_move_constructible::value): 233 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 234 | _first(first), _second(Utility::move(second)) 235 | #else 236 | _first{first}, _second{Utility::move(second)} 237 | #endif 238 | {} 239 | constexpr /*implicit*/ Pair(F&& first, const S& second) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_copy_constructible::value): 240 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 241 | _first(Utility::move(first)), _second(second) 242 | #else 243 | _first{Utility::move(first)}, _second{second} 244 | #endif 245 | {} 246 | constexpr /*implicit*/ Pair(F&& first, S&& second) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_move_constructible::value): 247 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 248 | _first(Utility::move(first)), _second(Utility::move(second)) 249 | #else 250 | _first{Utility::move(first)}, _second{Utility::move(second)} 251 | #endif 252 | {} 253 | 254 | template::value && std::is_constructible::value, int>::type = 0 256 | > constexpr explicit Pair(const Pair& other) noexcept(std::is_nothrow_constructible::value && std::is_nothrow_constructible::value): 257 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 258 | _first(F(other._first)), _second(S(other._second)) 259 | #else 260 | _first{F(other._first)}, _second{S(other._second)} 261 | #endif 262 | {} 263 | 264 | template::value && std::is_constructible::value, int>::type = 0 266 | > constexpr explicit Pair(Pair&& other) noexcept(std::is_nothrow_constructible::value && std::is_nothrow_constructible::value): 267 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 268 | _first(F(Utility::move(other._first))), _second(S(Utility::move(other._second))) 269 | #else 270 | _first{F(Utility::move(other._first))}, _second{S(Utility::move(other._second))} 271 | #endif 272 | {} 273 | 274 | template::from(std::declval()))> /*implicit*/ Pair(const T& other) noexcept(std::is_nothrow_copy_constructible::value && std::is_nothrow_copy_constructible::value): Pair{Implementation::PairConverter::from(other)} {} 275 | 276 | template::from(std::declval()))> /*implicit*/ Pair(T&& other) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_move_constructible::value): Pair{Implementation::PairConverter::from(Utility::move(other))} {} 277 | 278 | template::to(std::declval&>()))> /*implicit*/ operator T() const & { 279 | return Implementation::PairConverter::to(*this); 280 | } 281 | 282 | template::to(std::declval&&>()))> /*implicit*/ operator T() && { 283 | return Implementation::PairConverter::to(Utility::move(*this)); 284 | } 285 | 286 | constexpr bool operator==(const Pair& other) const { 287 | return _first == other._first && _second == other._second; 288 | } 289 | 290 | constexpr bool operator!=(const Pair& other) const { 291 | return !operator==(other); 292 | } 293 | 294 | CORRADE_CONSTEXPR14 F& first() & { return _first; } 295 | CORRADE_CONSTEXPR14 F first() && { return Utility::move(_first); } 296 | constexpr const F& first() const & { return _first; } 297 | 298 | CORRADE_CONSTEXPR14 S& second() & { return _second; } 299 | CORRADE_CONSTEXPR14 S second() && { return Utility::move(_second); } 300 | constexpr const S& second() const & { return _second; } 301 | 302 | private: 303 | template friend class Pair; 304 | 305 | #if CORRADE_CXX_STANDARD > 201402 306 | template::type = 0> constexpr friend const F& get(const Pair& value) { 307 | return value._first; 308 | } 309 | template::type = 0> CORRADE_CONSTEXPR14 friend F& get(Pair& value) { 310 | return value._first; 311 | } 312 | template::type = 0> CORRADE_CONSTEXPR14 friend F&& get(Pair&& value) { 313 | return Utility::move(value._first); 314 | } 315 | template::type = 0> constexpr friend const S& get(const Pair& value) { 316 | return value._second; 317 | } 318 | template::type = 0> CORRADE_CONSTEXPR14 friend S& get(Pair& value) { 319 | return value._second; 320 | } 321 | template::type = 0> CORRADE_CONSTEXPR14 friend S&& get(Pair&& value) { 322 | return Utility::move(value._second); 323 | } 324 | #endif 325 | 326 | F _first; 327 | S _second; 328 | }; 329 | 330 | template constexpr Pair::type, typename std::decay::type> pair(F&& first, S&& second) { 331 | return Pair::type, typename std::decay::type>{Utility::forward(first), Utility::forward(second)}; 332 | } 333 | 334 | namespace Implementation { 335 | template struct DeducedPairConverter; 336 | } 337 | 338 | template inline auto pair(T&& other) -> decltype(Implementation::DeducedPairConverter::type>::from(Utility::forward(other))) { 339 | return Implementation::DeducedPairConverter::type>::from(Utility::forward(other)); 340 | } 341 | 342 | }} 343 | 344 | #endif 345 | #ifdef CORRADE_PAIR_STL_COMPATIBILITY 346 | #include 347 | #ifndef Corrade_Containers_PairStl_h 348 | #define Corrade_Containers_PairStl_h 349 | 350 | namespace Corrade { namespace Containers { namespace Implementation { 351 | 352 | template struct PairConverter> { 353 | static Pair from(const std::pair& other) { 354 | return {other.first, other.second}; 355 | } 356 | 357 | static Pair from(std::pair&& other) { 358 | return {Utility::move(other.first), Utility::move(other.second)}; 359 | } 360 | 361 | static std::pair to(const Pair& other) { 362 | return {other.first(), other.second()}; 363 | } 364 | 365 | static std::pair to(Pair&& other) { 366 | return {Utility::move(other.first()), Utility::move(other.second())}; 367 | } 368 | }; 369 | 370 | template struct DeducedPairConverter>: PairConverter> {}; 371 | 372 | }}} 373 | 374 | #endif 375 | #endif 376 | #ifdef CORRADE_STRUCTURED_BINDINGS 377 | #if CORRADE_CXX_STANDARD >= 202002 378 | #include 379 | #else 380 | #include 381 | #endif 382 | #ifdef _LIBCPP_VERSION 383 | #define CORRADE_TARGET_LIBCXX 384 | #elif defined(_CPPLIB_VER) 385 | #define CORRADE_TARGET_DINKUMWARE 386 | #elif defined(__GLIBCXX__) 387 | #define CORRADE_TARGET_LIBSTDCXX 388 | #elif defined(__has_include) 389 | #if __has_include() 390 | #include 391 | #ifdef __GLIBCXX__ 392 | #define CORRADE_TARGET_LIBSTDCXX 393 | #endif 394 | #endif 395 | #elif defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5 396 | #define CORRADE_TARGET_LIBSTDCXX 397 | #else 398 | #endif 399 | #ifndef Corrade_Utility_StlForwardTupleSizeElement_h 400 | #define Corrade_Utility_StlForwardTupleSizeElement_h 401 | 402 | #ifdef CORRADE_TARGET_LIBCXX 403 | _LIBCPP_BEGIN_NAMESPACE_STD 404 | #elif defined(CORRADE_TARGET_LIBSTDCXX) 405 | #include 406 | namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION 407 | #elif defined(CORRADE_TARGET_DINKUMWARE) 408 | _STD_BEGIN 409 | #endif 410 | 411 | #if defined(CORRADE_TARGET_LIBCXX) || defined(CORRADE_TARGET_LIBSTDCXX) || defined(CORRADE_TARGET_DINKUMWARE) 412 | template struct tuple_element; 413 | template struct tuple_size; 414 | #else 415 | #include 416 | #endif 417 | 418 | #ifdef CORRADE_TARGET_LIBCXX 419 | _LIBCPP_END_NAMESPACE_STD 420 | #elif defined(CORRADE_TARGET_LIBSTDCXX) 421 | _GLIBCXX_END_NAMESPACE_VERSION } 422 | #elif defined CORRADE_TARGET_MSVC 423 | _STD_END 424 | #endif 425 | 426 | #endif 427 | namespace std { 428 | 429 | #ifndef Corrade_Containers_StructuredBindings_Pair_h 430 | #define Corrade_Containers_StructuredBindings_Pair_h 431 | template struct tuple_size>: integral_constant {}; 432 | template struct tuple_size>: integral_constant {}; 433 | template struct tuple_element<0, Corrade::Containers::Pair> { typedef F type; }; 434 | template struct tuple_element<1, Corrade::Containers::Pair> { typedef S type; }; 435 | template struct tuple_element> { 436 | typedef const typename tuple_element>::type type; 437 | }; 438 | #endif 439 | 440 | } 441 | #endif 442 | -------------------------------------------------------------------------------- /CorradePointer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Corrade::Containers::Pointer 3 | — a lightweight alternative to std::unique_ptr 4 | 5 | https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1Pointer.html 6 | 7 | This is a single-header library generated from the Corrade project. With 8 | the goal being easy integration, it's deliberately free of all comments 9 | to keep the file size small. More info, detailed changelogs and docs here: 10 | 11 | - Project homepage — https://magnum.graphics/corrade/ 12 | - Documentation — https://doc.magnum.graphics/corrade/ 13 | - GitHub project page — https://github.com/mosra/corrade 14 | - GitHub Singles repository — https://github.com/mosra/magnum-singles 15 | 16 | The STL compatibility bits are included as well --- opt-in by specifying 17 | `#define CORRADE_POINTER_STL_COMPATIBILITY` before including the file. 18 | Including it multiple times with different macros defined works too. 19 | 20 | v2020.06-1890-g77f9f (2025-04-11) 21 | - Cleanup and unification of SFINAE code, no functional change 22 | v2020.06-1687-g6b5f (2024-06-29) 23 | - Deleting pointers to incomplete types is now disallowed to prevent 24 | resource leaks 25 | - Conversion to non-trivial and non-virtual bases is now disallowed as 26 | doing so would no longer call the derived constructor, causing resource 27 | leaks 28 | v2020.06-1502-g147e (2023-09-11) 29 | - Fixes to the Utility::swap() helper to avoid ambiguity with std::swap() 30 | v2020.06-1454-gfc3b7 (2023-08-27) 31 | - The InPlaceInit tag is moved from Containers to the root namespace 32 | - The underlying type is exposed in a new Pointer::Type typedef 33 | - Added Pointer::emplace() for emplacing with a derived type 34 | - Further workarounds for various compiler-specific issues and standard 35 | defects when using {}-initialization for aggregate types 36 | - Removed dependency on , resulting in about ~600 preprocessed 37 | lines less 38 | v2020.06-0-g61d1b58c (2020-06-27) 39 | - Working around various compiler-specific issues and standard defects 40 | when using {}-initialization for aggregate types 41 | v2019.01-107-g80d9f347 (2019-03-23) 42 | - Including only when needed 43 | v2018.10-232-ge927d7f3 (2019-01-28) 44 | - Stricter matching for external representation conversion 45 | - Ability to convert from external representation also using pointer() 46 | v2018.10-183-g4eb1adc0 (2019-01-23) 47 | - Initial release 48 | 49 | Generated from Corrade v2020.06-1890-g77f9f (2025-04-11), 384 / 1784 LoC 50 | */ 51 | 52 | /* 53 | This file is part of Corrade. 54 | 55 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 56 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 57 | Vladimír Vondruš 58 | 59 | Permission is hereby granted, free of charge, to any person obtaining a 60 | copy of this software and associated documentation files (the "Software"), 61 | to deal in the Software without restriction, including without limitation 62 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 63 | and/or sell copies of the Software, and to permit persons to whom the 64 | Software is furnished to do so, subject to the following conditions: 65 | 66 | The above copyright notice and this permission notice shall be included 67 | in all copies or substantial portions of the Software. 68 | 69 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 70 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 71 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 72 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 73 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 74 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 75 | DEALINGS IN THE SOFTWARE. 76 | */ 77 | 78 | #include 79 | #if !defined(CORRADE_ASSERT) && !defined(NDEBUG) 80 | #include 81 | #endif 82 | 83 | #if defined(_MSC_VER) && _MSC_VER < 1910 84 | #define CORRADE_MSVC2015_COMPATIBILITY 85 | #endif 86 | 87 | #ifndef Corrade_Tags_h 88 | #define Corrade_Tags_h 89 | 90 | namespace Corrade { 91 | 92 | struct DefaultInitT { 93 | struct Init {}; 94 | constexpr explicit DefaultInitT(Init) {} 95 | }; 96 | 97 | struct ValueInitT { 98 | struct Init {}; 99 | constexpr explicit ValueInitT(Init) {} 100 | }; 101 | 102 | struct NoInitT { 103 | struct Init {}; 104 | constexpr explicit NoInitT(Init) {} 105 | }; 106 | 107 | struct NoCreateT { 108 | struct Init {}; 109 | constexpr explicit NoCreateT(Init) {} 110 | }; 111 | 112 | struct DirectInitT { 113 | struct Init {}; 114 | constexpr explicit DirectInitT(Init) {} 115 | }; 116 | 117 | struct InPlaceInitT { 118 | struct Init {}; 119 | constexpr explicit InPlaceInitT(Init) {} 120 | }; 121 | 122 | constexpr DefaultInitT DefaultInit{DefaultInitT::Init{}}; 123 | 124 | constexpr ValueInitT ValueInit{ValueInitT::Init{}}; 125 | 126 | constexpr NoInitT NoInit{NoInitT::Init{}}; 127 | 128 | constexpr NoCreateT NoCreate{NoCreateT::Init{}}; 129 | 130 | constexpr DirectInitT DirectInit{DirectInitT::Init{}}; 131 | 132 | constexpr InPlaceInitT InPlaceInit{InPlaceInitT::Init{}}; 133 | 134 | } 135 | 136 | #endif 137 | #ifndef Corrade_Utility_Move_h 138 | #define Corrade_Utility_Move_h 139 | 140 | #ifdef CORRADE_MSVC2015_COMPATIBILITY 141 | #include 142 | #endif 143 | 144 | namespace Corrade { namespace Utility { 145 | 146 | template constexpr T&& forward(typename std::remove_reference::type& t) noexcept { 147 | return static_cast(t); 148 | } 149 | 150 | template constexpr T&& forward(typename std::remove_reference::type&& t) noexcept { 151 | static_assert(!std::is_lvalue_reference::value, "T can't be a lvalue reference"); 152 | return static_cast(t); 153 | } 154 | 155 | template constexpr typename std::remove_reference::type&& move(T&& t) noexcept { 156 | return static_cast::type&&>(t); 157 | } 158 | 159 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 160 | template void swap(T& a, typename std::common_type::type& b) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_move_assignable::value) { 161 | T tmp = static_cast(a); 162 | a = static_cast(b); 163 | b = static_cast(tmp); 164 | } 165 | #else 166 | using std::swap; 167 | #endif 168 | 169 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 170 | template void swap(T(&a)[size], typename std::common_type::type b) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_move_assignable::value) { 171 | for(std::size_t i = 0; i != size; ++i) { 172 | T tmp = static_cast(a[i]); 173 | a[i] = static_cast(b[i]); 174 | b[i] = static_cast(tmp); 175 | } 176 | } 177 | #endif 178 | 179 | }} 180 | 181 | #endif 182 | #ifndef CORRADE_ASSERT 183 | #ifdef NDEBUG 184 | #define CORRADE_ASSERT(condition, message, returnValue) do {} while(false) 185 | #else 186 | #define CORRADE_ASSERT(condition, message, returnValue) assert(condition) 187 | #endif 188 | #endif 189 | #ifndef CORRADE_DEBUG_ASSERT 190 | #define CORRADE_DEBUG_ASSERT(condition, message, returnValue) \ 191 | CORRADE_ASSERT(condition, message, returnValue) 192 | #endif 193 | #ifndef Corrade_Containers_Pointer_h 194 | #define Corrade_Containers_Pointer_h 195 | 196 | namespace Corrade { namespace Containers { 197 | 198 | namespace Implementation { 199 | template struct PointerConverter; 200 | 201 | template inline T* allocate(First&& first, Next&& ...next) { 202 | return new T{Utility::forward(first), Utility::forward(next)...}; 203 | } 204 | template inline T* allocate() { 205 | return new T(); 206 | } 207 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 208 | template inline T* allocate(const T& b) { 209 | return new T(b); 210 | } 211 | template inline T* allocate(T&& b) { 212 | return new T(Utility::move(b)); 213 | } 214 | #endif 215 | 216 | namespace { template class IsComplete { 217 | template static char get(U*, decltype(sizeof(U))* = nullptr); 218 | static short get(...); 219 | public: 220 | enum: bool { value = sizeof(get(static_cast(nullptr))) == sizeof(char) }; 221 | }; } 222 | } 223 | 224 | template class Pointer { 225 | static_assert(!std::is_array::value, "use Containers::Array for arrays instead"); 226 | 227 | public: 228 | typedef T Type; 229 | 230 | template::value, int>::type = 0> /*implicit*/ Pointer(U) noexcept: _pointer{} {} 231 | /*implicit*/ Pointer() noexcept: _pointer{} {} 232 | 233 | explicit Pointer(T* pointer) noexcept: _pointer{pointer} {} 234 | 235 | template explicit Pointer(Corrade::InPlaceInitT, Args&&... args): _pointer{ 236 | Implementation::allocate(Utility::forward(args)...) 237 | } {} 238 | 239 | template::value, int>::type = 0 241 | > /*implicit*/ Pointer(Pointer&& other) noexcept: _pointer{other.release()} { 242 | static_assert(std::is_trivially_destructible::value || std::has_virtual_destructor::value, "the derived type should be trivially destructible or the base type should have a virtual destructor"); 243 | } 244 | 245 | template::from(std::declval()))> /*implicit*/ Pointer(U&& other) noexcept: Pointer{Implementation::PointerConverter::from(Utility::move(other))} {} 246 | 247 | Pointer(const Pointer&) = delete; 248 | 249 | Pointer(Pointer&& other) noexcept: _pointer{other._pointer} { 250 | other._pointer = nullptr; 251 | } 252 | 253 | Pointer& operator=(const Pointer&) = delete; 254 | 255 | Pointer& operator=(Pointer&& other) noexcept { 256 | Utility::swap(_pointer, other._pointer); 257 | return *this; 258 | } 259 | 260 | template::to(std::declval&&>()))> /*implicit*/ operator U() && { 261 | return Implementation::PointerConverter::to(Utility::move(*this)); 262 | } 263 | 264 | bool operator==(std::nullptr_t) const { return !_pointer; } 265 | 266 | bool operator!=(std::nullptr_t) const { return _pointer; } 267 | 268 | ~Pointer() { 269 | static_assert(Implementation::IsComplete::value, "attempting to delete a pointer to an incomplete type"); 270 | delete _pointer; 271 | } 272 | 273 | explicit operator bool() const { return _pointer; } 274 | 275 | T* get() { return _pointer; } 276 | const T* get() const { return _pointer; } 277 | 278 | T* operator->() { 279 | CORRADE_DEBUG_ASSERT(_pointer, "Containers::Pointer: the pointer is null", nullptr); 280 | return _pointer; 281 | } 282 | 283 | const T* operator->() const { 284 | CORRADE_DEBUG_ASSERT(_pointer, "Containers::Pointer: the pointer is null", nullptr); 285 | return _pointer; 286 | } 287 | 288 | T& operator*() { 289 | CORRADE_DEBUG_ASSERT(_pointer, "Containers::Pointer: the pointer is null", *_pointer); 290 | return *_pointer; 291 | } 292 | 293 | const T& operator*() const { 294 | CORRADE_DEBUG_ASSERT(_pointer, "Containers::Pointer: the pointer is null", *_pointer); 295 | return *_pointer; 296 | } 297 | 298 | void reset(T* pointer = nullptr) { 299 | static_assert(Implementation::IsComplete::value, "attempting to delete a pointer to an incomplete type"); 300 | delete _pointer; 301 | _pointer = pointer; 302 | } 303 | 304 | template T& emplace(Args&&... args) { 305 | delete _pointer; 306 | _pointer = Implementation::allocate(Utility::forward(args)...); 307 | return *_pointer; 308 | } 309 | 310 | template U& emplace(Args&&... args) { 311 | static_assert(std::is_trivially_destructible::value || std::has_virtual_destructor::value, "the derived type should be trivially destructible or the base type should have a virtual destructor"); 312 | delete _pointer; 313 | U* const derived = Implementation::allocate(Utility::forward(args)...); 314 | _pointer = derived; 315 | return *derived; 316 | } 317 | 318 | T* release() { 319 | T* const out = _pointer; 320 | _pointer = nullptr; 321 | return out; 322 | } 323 | 324 | private: 325 | T* _pointer; 326 | }; 327 | 328 | template bool operator==(std::nullptr_t, const Pointer& b) { return b == nullptr; } 329 | 330 | template bool operator!=(std::nullptr_t, const Pointer& b) { return b != nullptr; } 331 | 332 | template inline Pointer pointer(T* pointer) { 333 | static_assert(!std::is_constructible::value, "the type is constructible from its own pointer, which is ambiguous -- explicitly use the constructor instead"); 334 | return Pointer{pointer}; 335 | } 336 | 337 | namespace Implementation { 338 | template struct DeducedPointerConverter; 339 | } 340 | 341 | template inline auto pointer(T&& other) -> decltype(Implementation::DeducedPointerConverter::from(Utility::move(other))) { 342 | return Implementation::DeducedPointerConverter::from(Utility::move(other)); 343 | } 344 | 345 | template Pointer pointerCast(Pointer&& pointer) { 346 | return Pointer{static_cast(pointer.release())}; 347 | } 348 | 349 | namespace Implementation { 350 | template struct IsFirstAPointer: std::false_type {}; 351 | template struct IsFirstAPointer: std::true_type {}; 352 | } 353 | 354 | template inline Pointer pointer(Args&&... args) { 355 | static_assert(!Implementation::IsFirstAPointer::value || !std::is_constructible::value, "attempt to construct a type from its own pointer, which is ambiguous -- explicitly use the constructor instead"); 356 | return Pointer{Corrade::InPlaceInit, Utility::forward(args)...}; 357 | } 358 | 359 | }} 360 | 361 | #endif 362 | #ifdef CORRADE_POINTER_STL_COMPATIBILITY 363 | #include 364 | #ifndef Corrade_Containers_PointerStl_h 365 | #define Corrade_Containers_PointerStl_h 366 | 367 | namespace Corrade { namespace Containers { namespace Implementation { 368 | 369 | template struct PointerConverter> { 370 | static Pointer from(std::unique_ptr&& other) { 371 | return Pointer{other.release()}; 372 | } 373 | 374 | static std::unique_ptr to(Pointer&& other) { 375 | return std::unique_ptr{other.release()}; 376 | } 377 | }; 378 | 379 | template struct DeducedPointerConverter>: PointerConverter> {}; 380 | 381 | }}} 382 | 383 | #endif 384 | #endif 385 | -------------------------------------------------------------------------------- /CorradeReference.h: -------------------------------------------------------------------------------- 1 | /* 2 | Corrade::Containers::Reference 3 | — a lightweight alternative to std::reference_wrapper 4 | 5 | https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1Reference.html 6 | 7 | This is a single-header library generated from the Corrade project. With 8 | the goal being easy integration, it's deliberately free of all comments 9 | to keep the file size small. More info, detailed changelogs and docs here: 10 | 11 | - Project homepage — https://magnum.graphics/corrade/ 12 | - Documentation — https://doc.magnum.graphics/corrade/ 13 | - GitHub project page — https://github.com/mosra/corrade 14 | - GitHub Singles repository — https://github.com/mosra/magnum-singles 15 | 16 | The STL compatibility bits are included as well --- opt-in by specifying 17 | `#define CORRADE_REFERENCE_STL_COMPATIBILITY` before including the file. 18 | Including it multiple times with different macros defined works too. 19 | 20 | v2020.06-1890-g77f9f (2025-04-11) 21 | - Cleanup and unification of SFINAE code, no functional change 22 | v2020.06-1687-g6b5f (2024-06-29) 23 | - Added a reference() helper for convenient construction 24 | v2020.06-1459-g65d9b (2023-08-28) 25 | - Fixed a copypaste error in the STL compatibility opt-in macro 26 | v2020.06-1454-gfc3b7 (2023-08-27) 27 | - The underlying type is exposed in a new Reference::Type typedef 28 | - Removed unnecessary function calls for improved debug performace 29 | v2018.10-232-ge927d7f3 (2019-01-28) 30 | - Stricter matching for external representation conversion 31 | - Fixed STL compatibility to not recurse infinitely 32 | v2018.10-183-g4eb1adc0 (2019-01-23) 33 | - Initial release 34 | 35 | Generated from Corrade v2020.06-1890-g77f9f (2025-04-11), 135 / 1628 LoC 36 | */ 37 | 38 | /* 39 | This file is part of Corrade. 40 | 41 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 42 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 43 | Vladimír Vondruš 44 | 45 | Permission is hereby granted, free of charge, to any person obtaining a 46 | copy of this software and associated documentation files (the "Software"), 47 | to deal in the Software without restriction, including without limitation 48 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 49 | and/or sell copies of the Software, and to permit persons to whom the 50 | Software is furnished to do so, subject to the following conditions: 51 | 52 | The above copyright notice and this permission notice shall be included 53 | in all copies or substantial portions of the Software. 54 | 55 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 56 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 57 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 58 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 59 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 60 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 61 | DEALINGS IN THE SOFTWARE. 62 | */ 63 | 64 | #include 65 | 66 | #ifndef Corrade_Containers_Reference_h 67 | #define Corrade_Containers_Reference_h 68 | 69 | namespace Corrade { namespace Containers { 70 | 71 | namespace Implementation { 72 | template struct ReferenceConverter; 73 | } 74 | 75 | template class Reference { 76 | public: 77 | typedef T Type; 78 | 79 | constexpr /*implicit*/ Reference(T& reference) noexcept: _reference{&reference} {} 80 | 81 | template::from(std::declval()))> constexpr /*implicit*/ Reference(U other) noexcept: Reference{Implementation::ReferenceConverter::from(other)} {} 82 | 83 | Reference(T&&) = delete; 84 | 85 | template::value, int>::type = 0 87 | > constexpr /*implicit*/ Reference(Reference other) noexcept: _reference{other._reference} {} 88 | 89 | template::to(std::declval>()))> constexpr /*implicit*/ operator U() const { 90 | return Implementation::ReferenceConverter::to(*this); 91 | } 92 | 93 | constexpr /*implicit*/ operator T&() const { return *_reference; } 94 | constexpr /*implicit*/ operator Reference() const { return *_reference; } 95 | 96 | constexpr T& get() const { return *_reference; } 97 | 98 | constexpr T* operator->() const { return _reference; } 99 | 100 | constexpr T& operator*() const { return *_reference; } 101 | 102 | private: 103 | template friend class Reference; 104 | 105 | T* _reference; 106 | }; 107 | 108 | template constexpr Reference reference(T& reference) { 109 | return Reference{reference}; 110 | } 111 | 112 | }} 113 | 114 | #endif 115 | #ifdef CORRADE_REFERENCE_STL_COMPATIBILITY 116 | #include 117 | #ifndef Corrade_Containers_ReferenceStl_h 118 | #define Corrade_Containers_ReferenceStl_h 119 | 120 | namespace Corrade { namespace Containers { namespace Implementation { 121 | 122 | template struct ReferenceConverter> { 123 | static Reference from(std::reference_wrapper other) { 124 | return other.get(); 125 | } 126 | 127 | static std::reference_wrapper to(Reference other) { 128 | return other.get(); 129 | } 130 | }; 131 | 132 | }}} 133 | 134 | #endif 135 | #endif 136 | -------------------------------------------------------------------------------- /CorradeScopeGuard.h: -------------------------------------------------------------------------------- 1 | /* 2 | Corrade::Containers::ScopeGuard 3 | — a lightweight alternative to std::unique_ptr with a custom deleter 4 | 5 | https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1ScopeGuard.html 6 | 7 | This is a single-header library generated from the Corrade project. With 8 | the goal being easy integration, it's deliberately free of all comments 9 | to keep the file size small. More info, detailed changelogs and docs here: 10 | 11 | - Project homepage — https://magnum.graphics/corrade/ 12 | - Documentation — https://doc.magnum.graphics/corrade/ 13 | - GitHub project page — https://github.com/mosra/corrade 14 | - GitHub Singles repository — https://github.com/mosra/magnum-singles 15 | 16 | v2020.06-1687-g6b5f (2024-06-29) 17 | - Suppressing a "conversion from T to void * of greater size" warning 18 | that could happen with certain type sizes on MSVC 19 | v2020.06-1502-g147e (2023-09-11) 20 | - Fixes to the Utility::swap() helper to avoid ambiguity with std::swap() 21 | v2020.06-1454-gfc3b7 (2023-08-27) 22 | - Ability to construct a NoCreate'd ScopeGuard and then move a complete 23 | instance over it 24 | v2019.01-41-g39c08d7c (2019-02-18) 25 | - Ability to create a handle-less ScopeGuard 26 | v2018.10-232-ge927d7f3 (2019-01-28) 27 | - Initial release 28 | 29 | Generated from Corrade v2020.06-1687-g6b5f (2024-06-29), 263 / 1706 LoC 30 | */ 31 | 32 | /* 33 | This file is part of Corrade. 34 | 35 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 36 | 2017, 2018, 2019, 2020, 2021, 2022, 2023 37 | Vladimír Vondruš 38 | 39 | Permission is hereby granted, free of charge, to any person obtaining a 40 | copy of this software and associated documentation files (the "Software"), 41 | to deal in the Software without restriction, including without limitation 42 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 43 | and/or sell copies of the Software, and to permit persons to whom the 44 | Software is furnished to do so, subject to the following conditions: 45 | 46 | The above copyright notice and this permission notice shall be included 47 | in all copies or substantial portions of the Software. 48 | 49 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 50 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 51 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 52 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 53 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 54 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 55 | DEALINGS IN THE SOFTWARE. 56 | */ 57 | 58 | #include 59 | 60 | #ifdef _MSC_VER 61 | #define CORRADE_TARGET_MSVC 62 | #endif 63 | #if defined(_MSC_VER) && _MSC_VER < 1910 64 | #define CORRADE_MSVC2015_COMPATIBILITY 65 | #endif 66 | 67 | #ifndef Corrade_Tags_h 68 | #define Corrade_Tags_h 69 | 70 | namespace Corrade { 71 | 72 | struct DefaultInitT { 73 | struct Init {}; 74 | constexpr explicit DefaultInitT(Init) {} 75 | }; 76 | 77 | struct ValueInitT { 78 | struct Init {}; 79 | constexpr explicit ValueInitT(Init) {} 80 | }; 81 | 82 | struct NoInitT { 83 | struct Init {}; 84 | constexpr explicit NoInitT(Init) {} 85 | }; 86 | 87 | struct NoCreateT { 88 | struct Init {}; 89 | constexpr explicit NoCreateT(Init) {} 90 | }; 91 | 92 | struct DirectInitT { 93 | struct Init {}; 94 | constexpr explicit DirectInitT(Init) {} 95 | }; 96 | 97 | struct InPlaceInitT { 98 | struct Init {}; 99 | constexpr explicit InPlaceInitT(Init) {} 100 | }; 101 | 102 | constexpr DefaultInitT DefaultInit{DefaultInitT::Init{}}; 103 | 104 | constexpr ValueInitT ValueInit{ValueInitT::Init{}}; 105 | 106 | constexpr NoInitT NoInit{NoInitT::Init{}}; 107 | 108 | constexpr NoCreateT NoCreate{NoCreateT::Init{}}; 109 | 110 | constexpr DirectInitT DirectInit{DirectInitT::Init{}}; 111 | 112 | constexpr InPlaceInitT InPlaceInit{InPlaceInitT::Init{}}; 113 | 114 | } 115 | 116 | #endif 117 | #ifndef Corrade_Utility_Move_h 118 | #define Corrade_Utility_Move_h 119 | 120 | #ifdef CORRADE_MSVC2015_COMPATIBILITY 121 | #include 122 | #endif 123 | 124 | namespace Corrade { namespace Utility { 125 | 126 | template constexpr T&& forward(typename std::remove_reference::type& t) noexcept { 127 | return static_cast(t); 128 | } 129 | 130 | template constexpr T&& forward(typename std::remove_reference::type&& t) noexcept { 131 | static_assert(!std::is_lvalue_reference::value, "T can't be a lvalue reference"); 132 | return static_cast(t); 133 | } 134 | 135 | template constexpr typename std::remove_reference::type&& move(T&& t) noexcept { 136 | return static_cast::type&&>(t); 137 | } 138 | 139 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 140 | template void swap(T& a, typename std::common_type::type& b) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_move_assignable::value) { 141 | T tmp = static_cast(a); 142 | a = static_cast(b); 143 | b = static_cast(tmp); 144 | } 145 | #else 146 | using std::swap; 147 | #endif 148 | 149 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 150 | template void swap(T(&a)[size], typename std::common_type::type b) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_move_assignable::value) { 151 | for(std::size_t i = 0; i != size; ++i) { 152 | T tmp = static_cast(a[i]); 153 | a[i] = static_cast(b[i]); 154 | b[i] = static_cast(tmp); 155 | } 156 | } 157 | #endif 158 | 159 | }} 160 | 161 | #endif 162 | #ifndef Corrade_Containers_ScopeGuard_h 163 | #define Corrade_Containers_ScopeGuard_h 164 | 165 | namespace Corrade { namespace Containers { 166 | 167 | class ScopeGuard { 168 | public: 169 | template explicit ScopeGuard(T handle, Deleter deleter); 170 | 171 | template explicit ScopeGuard(Deleter deleter); 172 | 173 | #ifdef CORRADE_MSVC2015_COMPATIBILITY 174 | template explicit ScopeGuard(T handle, U(*deleter)(T)); 175 | template explicit ScopeGuard(U(*deleter)()); 176 | #endif 177 | 178 | explicit ScopeGuard(Corrade::NoCreateT) noexcept: _deleterWrapper{}, _deleter{}, _handle{} {} 179 | 180 | ScopeGuard(const ScopeGuard&) = delete; 181 | 182 | ScopeGuard(ScopeGuard&& other) noexcept; 183 | 184 | ScopeGuard& operator=(const ScopeGuard&) = delete; 185 | 186 | ScopeGuard& operator=(ScopeGuard&&) noexcept; 187 | 188 | void release() { _deleterWrapper = nullptr; } 189 | 190 | ~ScopeGuard() { 191 | if(_deleterWrapper) _deleterWrapper(&_deleter, &_handle); 192 | } 193 | 194 | private: 195 | void(*_deleterWrapper)(void(**)(), void**); 196 | void(*_deleter)(); 197 | void* _handle; 198 | }; 199 | 200 | template ScopeGuard::ScopeGuard(T handle, Deleter deleter): _deleter{ 201 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 202 | reinterpret_cast(+deleter) 203 | #else 204 | reinterpret_cast(static_cast(deleter)) 205 | #endif 206 | }, _handle{ 207 | #ifdef CORRADE_TARGET_MSVC 208 | #pragma warning(push) 209 | #pragma warning(disable: 4312) 210 | #endif 211 | reinterpret_cast(handle) 212 | #ifdef CORRADE_TARGET_MSVC 213 | #pragma warning(pop) 214 | #endif 215 | } { 216 | static_assert(sizeof(T) <= sizeof(void*), "handle too big to store"); 217 | _deleterWrapper = [](void(**deleter)(), void** handle) { 218 | (*reinterpret_cast(deleter))(*reinterpret_cast(handle)); 219 | }; 220 | } 221 | 222 | template ScopeGuard::ScopeGuard(Deleter deleter): _deleter{ 223 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 224 | reinterpret_cast(+deleter) 225 | #else 226 | reinterpret_cast(static_cast(deleter)) 227 | #endif 228 | }, _handle{nullptr} { 229 | _deleterWrapper = [](void(**deleter)(), void**) { 230 | (*reinterpret_cast(deleter))(); 231 | }; 232 | } 233 | 234 | inline ScopeGuard::ScopeGuard(ScopeGuard&& other) noexcept: _deleterWrapper{other._deleterWrapper}, _deleter{other._deleter}, _handle{other._handle} { 235 | other._deleterWrapper = nullptr; 236 | } 237 | 238 | inline ScopeGuard& ScopeGuard::operator=(ScopeGuard&& other) noexcept { 239 | using Utility::swap; 240 | swap(other._deleterWrapper, _deleterWrapper); 241 | swap(other._deleter, _deleter); 242 | swap(other._handle, _handle); 243 | return *this; 244 | } 245 | 246 | #ifdef CORRADE_MSVC2015_COMPATIBILITY 247 | template ScopeGuard::ScopeGuard(T handle, U(*deleter)(T)): _deleter{reinterpret_cast(deleter)}, _handle{reinterpret_cast(handle)} { 248 | static_assert(sizeof(T) <= sizeof(void*), "handle too big to store"); 249 | _deleterWrapper = [](void(**deleter)(), void** handle) { 250 | (*reinterpret_cast(deleter))(*reinterpret_cast(handle)); 251 | }; 252 | } 253 | 254 | template ScopeGuard::ScopeGuard(U(*deleter)()): _deleter{reinterpret_cast(deleter)}, _handle{nullptr} { 255 | _deleterWrapper = [](void(**deleter)(), void**) { 256 | (*reinterpret_cast(deleter))(); 257 | }; 258 | } 259 | #endif 260 | 261 | }} 262 | 263 | #endif 264 | -------------------------------------------------------------------------------- /CorradeStlForwardArray.h: -------------------------------------------------------------------------------- 1 | /* 2 | Corrade's forward declaration for std::array 3 | — a lightweight alternative to the full where supported 4 | 5 | https://doc.magnum.graphics/corrade/StlForwardArray_8h.html 6 | 7 | This is a single-header library generated from the Corrade project. With 8 | the goal being easy integration, it's deliberately free of all comments 9 | to keep the file size small. More info, detailed changelogs and docs here: 10 | 11 | - Project homepage — https://magnum.graphics/corrade/ 12 | - Documentation — https://doc.magnum.graphics/corrade/ 13 | - GitHub project page — https://github.com/mosra/corrade 14 | - GitHub Singles repository — https://github.com/mosra/magnum-singles 15 | 16 | v2020.06-1454-gfc3b7 (2023-08-27) 17 | - Compatibility with libc++ 16 and newer which has the std::array forward 18 | declaration in a different header 19 | - Compatibility with C++20 which removes the header 20 | v2019.01-115-ged348b26 (2019-03-27) 21 | - Initial release 22 | 23 | Generated from Corrade v2020.06-1454-gfc3b7 (2023-08-27), 88 / 2003 LoC 24 | */ 25 | 26 | /* 27 | This file is part of Corrade. 28 | 29 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 30 | 2017, 2018, 2019, 2020, 2021, 2022, 2023 31 | Vladimír Vondruš 32 | 33 | Permission is hereby granted, free of charge, to any person obtaining a 34 | copy of this software and associated documentation files (the "Software"), 35 | to deal in the Software without restriction, including without limitation 36 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 37 | and/or sell copies of the Software, and to permit persons to whom the 38 | Software is furnished to do so, subject to the following conditions: 39 | 40 | The above copyright notice and this permission notice shall be included 41 | in all copies or substantial portions of the Software. 42 | 43 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 44 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 45 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 46 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 47 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 48 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 49 | DEALINGS IN THE SOFTWARE. 50 | */ 51 | 52 | #ifdef _MSC_VER 53 | #ifdef _MSVC_LANG 54 | #define CORRADE_CXX_STANDARD _MSVC_LANG 55 | #else 56 | #define CORRADE_CXX_STANDARD 201103L 57 | #endif 58 | #else 59 | #define CORRADE_CXX_STANDARD __cplusplus 60 | #endif 61 | #if CORRADE_CXX_STANDARD >= 202002 62 | #include 63 | #else 64 | #include 65 | #endif 66 | #ifdef _LIBCPP_VERSION 67 | #define CORRADE_TARGET_LIBCXX 68 | #elif defined(_CPPLIB_VER) 69 | #define CORRADE_TARGET_DINKUMWARE 70 | #else 71 | #endif 72 | 73 | #ifndef Corrade_Utility_StlForwardArray_h 74 | #define Corrade_Utility_StlForwardArray_h 75 | 76 | #ifdef CORRADE_TARGET_LIBCXX 77 | #if _LIBCPP_VERSION < 160000 78 | #include <__tuple> 79 | #else 80 | #include <__fwd/array.h> 81 | #endif 82 | #elif defined(CORRADE_TARGET_DINKUMWARE) 83 | #include 84 | #else 85 | #include 86 | #endif 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /CorradeStlForwardString.h: -------------------------------------------------------------------------------- 1 | /* 2 | Corrade's forward declaration for std::string 3 | — a lightweight alternative to the full where supported 4 | 5 | https://doc.magnum.graphics/corrade/StlForwardString_8h.html 6 | 7 | This is a single-header library generated from the Corrade project. With 8 | the goal being easy integration, it's deliberately free of all comments 9 | to keep the file size small. More info, detailed changelogs and docs here: 10 | 11 | - Project homepage — https://magnum.graphics/corrade/ 12 | - Documentation — https://doc.magnum.graphics/corrade/ 13 | - GitHub project page — https://github.com/mosra/corrade 14 | - GitHub Singles repository — https://github.com/mosra/magnum-singles 15 | 16 | v2020.06-1454-gfc3b7 (2023-08-27) 17 | - Compatibility with C++20 which removes the header 18 | v2019.01-115-ged348b26 (2019-03-27) 19 | - Initial release 20 | 21 | Generated from Corrade v2020.06-1454-gfc3b7 (2023-08-27), 89 / 68 LoC 22 | */ 23 | 24 | /* 25 | This file is part of Corrade. 26 | 27 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 28 | 2017, 2018, 2019, 2020, 2021, 2022, 2023 29 | Vladimír Vondruš 30 | 31 | Permission is hereby granted, free of charge, to any person obtaining a 32 | copy of this software and associated documentation files (the "Software"), 33 | to deal in the Software without restriction, including without limitation 34 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 35 | and/or sell copies of the Software, and to permit persons to whom the 36 | Software is furnished to do so, subject to the following conditions: 37 | 38 | The above copyright notice and this permission notice shall be included 39 | in all copies or substantial portions of the Software. 40 | 41 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 42 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 43 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 44 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 45 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 46 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 47 | DEALINGS IN THE SOFTWARE. 48 | */ 49 | 50 | #ifdef _MSC_VER 51 | #ifdef _MSVC_LANG 52 | #define CORRADE_CXX_STANDARD _MSVC_LANG 53 | #else 54 | #define CORRADE_CXX_STANDARD 201103L 55 | #endif 56 | #else 57 | #define CORRADE_CXX_STANDARD __cplusplus 58 | #endif 59 | #if CORRADE_CXX_STANDARD >= 202002 60 | #include 61 | #else 62 | #include 63 | #endif 64 | #ifdef _LIBCPP_VERSION 65 | #define CORRADE_TARGET_LIBCXX 66 | #elif defined(__GLIBCXX__) 67 | #define CORRADE_TARGET_LIBSTDCXX 68 | #elif defined(__has_include) 69 | #if __has_include() 70 | #include 71 | #ifdef __GLIBCXX__ 72 | #define CORRADE_TARGET_LIBSTDCXX 73 | #endif 74 | #endif 75 | #else 76 | #endif 77 | 78 | #ifndef Corrade_Utility_StlForwardString_h 79 | #define Corrade_Utility_StlForwardString_h 80 | 81 | #ifdef CORRADE_TARGET_LIBCXX 82 | #include 83 | #elif defined(CORRADE_TARGET_LIBSTDCXX) 84 | #include 85 | #else 86 | #include 87 | #endif 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /CorradeStlForwardTuple.h: -------------------------------------------------------------------------------- 1 | /* 2 | Corrade's forward declaration for std::tuple 3 | — a lightweight alternative to the full where supported 4 | 5 | https://doc.magnum.graphics/corrade/StlForwardTuple_8h.html 6 | 7 | This is a single-header library generated from the Corrade project. With 8 | the goal being easy integration, it's deliberately free of all comments 9 | to keep the file size small. More info, detailed changelogs and docs here: 10 | 11 | - Project homepage — https://magnum.graphics/corrade/ 12 | - Documentation — https://doc.magnum.graphics/corrade/ 13 | - GitHub project page — https://github.com/mosra/corrade 14 | - GitHub Singles repository — https://github.com/mosra/magnum-singles 15 | 16 | v2020.06-1454-gfc3b7 (2023-08-27) 17 | - Compatibility with libc++ 16 and newer and libstdc++ 12 and newer which 18 | have the std::tuple forward declaration in a different header 19 | - Compatibility with C++20 which removes the header 20 | v2019.01-115-ged348b26 (2019-03-27) 21 | - Initial release 22 | 23 | Generated from Corrade v2020.06-1454-gfc3b7 (2023-08-27), 102 / 2228 LoC 24 | */ 25 | 26 | /* 27 | This file is part of Corrade. 28 | 29 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 30 | 2017, 2018, 2019, 2020, 2021, 2022, 2023 31 | Vladimír Vondruš 32 | 33 | Permission is hereby granted, free of charge, to any person obtaining a 34 | copy of this software and associated documentation files (the "Software"), 35 | to deal in the Software without restriction, including without limitation 36 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 37 | and/or sell copies of the Software, and to permit persons to whom the 38 | Software is furnished to do so, subject to the following conditions: 39 | 40 | The above copyright notice and this permission notice shall be included 41 | in all copies or substantial portions of the Software. 42 | 43 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 44 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 45 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 46 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 47 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 48 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 49 | DEALINGS IN THE SOFTWARE. 50 | */ 51 | 52 | #ifdef _MSC_VER 53 | #ifdef _MSVC_LANG 54 | #define CORRADE_CXX_STANDARD _MSVC_LANG 55 | #else 56 | #define CORRADE_CXX_STANDARD 201103L 57 | #endif 58 | #else 59 | #define CORRADE_CXX_STANDARD __cplusplus 60 | #endif 61 | #if CORRADE_CXX_STANDARD >= 202002 62 | #include 63 | #else 64 | #include 65 | #endif 66 | #ifdef _LIBCPP_VERSION 67 | #define CORRADE_TARGET_LIBCXX 68 | #elif defined(_CPPLIB_VER) 69 | #define CORRADE_TARGET_DINKUMWARE 70 | #elif defined(__GLIBCXX__) 71 | #define CORRADE_TARGET_LIBSTDCXX 72 | #elif defined(__has_include) 73 | #if __has_include() 74 | #include 75 | #ifdef __GLIBCXX__ 76 | #define CORRADE_TARGET_LIBSTDCXX 77 | #endif 78 | #endif 79 | #else 80 | #endif 81 | 82 | #ifndef Corrade_Utility_StlForwardTuple_h 83 | #define Corrade_Utility_StlForwardTuple_h 84 | 85 | #ifdef CORRADE_TARGET_LIBCXX 86 | #if _LIBCPP_VERSION < 160000 87 | #include <__tuple> 88 | #else 89 | #include <__fwd/tuple.h> 90 | #endif 91 | #elif defined(CORRADE_TARGET_LIBSTDCXX) 92 | #if _GLIBCXX_RELEASE >= 7 && _GLIBCXX_RELEASE < 12 93 | #include 94 | #else 95 | #include 96 | #endif 97 | #elif defined(CORRADE_TARGET_DINKUMWARE) 98 | #else 99 | #include 100 | #endif 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /CorradeStlForwardVector.h: -------------------------------------------------------------------------------- 1 | /* 2 | Corrade's forward declaration for std::vector 3 | — a lightweight alternative to the full where supported 4 | 5 | https://doc.magnum.graphics/corrade/StlForwardVector_8h.html 6 | 7 | This is a single-header library generated from the Corrade project. With 8 | the goal being easy integration, it's deliberately free of all comments 9 | to keep the file size small. More info, detailed changelogs and docs here: 10 | 11 | - Project homepage — https://magnum.graphics/corrade/ 12 | - Documentation — https://doc.magnum.graphics/corrade/ 13 | - GitHub project page — https://github.com/mosra/corrade 14 | - GitHub Singles repository — https://github.com/mosra/magnum-singles 15 | 16 | v2020.06-1846-gc4cdf (2025-01-07) 17 | - Adapted to changes in libc++ 19.1.0 18 | v2020.06-1454-gfc3b7 (2023-08-27) 19 | - Compatibility with C++20 which removes the header 20 | v2019.01-115-ged348b26 (2019-03-27) 21 | - Initial release 22 | 23 | Generated from Corrade v2020.06-1846-gc4cdf (2025-01-07), 81 / 181 LoC 24 | */ 25 | 26 | /* 27 | This file is part of Corrade. 28 | 29 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 30 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 31 | Vladimír Vondruš 32 | 33 | Permission is hereby granted, free of charge, to any person obtaining a 34 | copy of this software and associated documentation files (the "Software"), 35 | to deal in the Software without restriction, including without limitation 36 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 37 | and/or sell copies of the Software, and to permit persons to whom the 38 | Software is furnished to do so, subject to the following conditions: 39 | 40 | The above copyright notice and this permission notice shall be included 41 | in all copies or substantial portions of the Software. 42 | 43 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 44 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 45 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 46 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 47 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 48 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 49 | DEALINGS IN THE SOFTWARE. 50 | */ 51 | 52 | #ifdef _MSC_VER 53 | #ifdef _MSVC_LANG 54 | #define CORRADE_CXX_STANDARD _MSVC_LANG 55 | #else 56 | #define CORRADE_CXX_STANDARD 201103L 57 | #endif 58 | #else 59 | #define CORRADE_CXX_STANDARD __cplusplus 60 | #endif 61 | #if CORRADE_CXX_STANDARD >= 202002 62 | #include 63 | #else 64 | #include 65 | #endif 66 | #ifdef _LIBCPP_VERSION 67 | #define CORRADE_TARGET_LIBCXX 68 | #endif 69 | 70 | #ifndef Corrade_Utility_StlForwardVector_h 71 | #define Corrade_Utility_StlForwardVector_h 72 | 73 | #if defined(CORRADE_TARGET_LIBCXX) && _LIBCPP_VERSION >= 190100 74 | #include <__fwd/vector.h> 75 | #elif defined(CORRADE_TARGET_LIBCXX) && _LIBCPP_VERSION >= 3900 76 | #include 77 | #else 78 | #include 79 | #endif 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /CorradeStlMath.h: -------------------------------------------------------------------------------- 1 | /* 2 | Corrade's optimized , without the heavy C++17 additions 3 | 4 | https://doc.magnum.graphics/corrade/StlMath_8h.html 5 | 6 | This is a single-header library generated from the Corrade project. With 7 | the goal being easy integration, it's deliberately free of all comments 8 | to keep the file size small. More info, detailed changelogs and docs here: 9 | 10 | - Project homepage — https://magnum.graphics/corrade/ 11 | - Documentation — https://doc.magnum.graphics/corrade/ 12 | - GitHub project page — https://github.com/mosra/corrade 13 | - GitHub Singles repository — https://github.com/mosra/magnum-singles 14 | 15 | v2020.06-1454-gfc3b7 (2023-08-27) 16 | - Compatibility with C++20 which removes the header 17 | v2019.01-186-gdd93f1f1 (2019-06-06) 18 | - Initial release 19 | 20 | Generated from Corrade v2020.06-1454-gfc3b7 (2023-08-27), 73 / 3222 LoC 21 | */ 22 | 23 | /* 24 | This file is part of Corrade. 25 | 26 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 27 | 2017, 2018, 2019, 2020, 2021, 2022, 2023 28 | Vladimír Vondruš 29 | 30 | Permission is hereby granted, free of charge, to any person obtaining a 31 | copy of this software and associated documentation files (the "Software"), 32 | to deal in the Software without restriction, including without limitation 33 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 34 | and/or sell copies of the Software, and to permit persons to whom the 35 | Software is furnished to do so, subject to the following conditions: 36 | 37 | The above copyright notice and this permission notice shall be included 38 | in all copies or substantial portions of the Software. 39 | 40 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 41 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 42 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 43 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 44 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 45 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 46 | DEALINGS IN THE SOFTWARE. 47 | */ 48 | 49 | #ifdef _MSC_VER 50 | #ifdef _MSVC_LANG 51 | #define CORRADE_CXX_STANDARD _MSVC_LANG 52 | #else 53 | #define CORRADE_CXX_STANDARD 201103L 54 | #endif 55 | #else 56 | #define CORRADE_CXX_STANDARD __cplusplus 57 | #endif 58 | #if CORRADE_CXX_STANDARD >= 202002 59 | #include 60 | #else 61 | #include 62 | #endif 63 | 64 | #ifndef Corrade_Utility_StlMath_h 65 | #define Corrade_Utility_StlMath_h 66 | 67 | #ifdef _GLIBCXX_USE_STD_SPEC_FUNCS 68 | #undef _GLIBCXX_USE_STD_SPEC_FUNCS 69 | #define _GLIBCXX_USE_STD_SPEC_FUNCS 0 70 | #endif 71 | #include 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /CorradeTriple.h: -------------------------------------------------------------------------------- 1 | /* 2 | Corrade::Containers::Triple 3 | — a lightweight alternative to a three-component std::tuple 4 | 5 | https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1Triple.html 6 | 7 | This is a single-header library generated from the Corrade project. With 8 | the goal being easy integration, it's deliberately free of all comments 9 | to keep the file size small. More info, detailed changelogs and docs here: 10 | 11 | - Project homepage — https://magnum.graphics/corrade/ 12 | - Documentation — https://doc.magnum.graphics/corrade/ 13 | - GitHub project page — https://github.com/mosra/corrade 14 | - GitHub Singles repository — https://github.com/mosra/magnum-singles 15 | 16 | Structured bindings on C++17 are opt-in due to reliance on a potentially 17 | heavy STL header --- `#define CORRADE_STRUCTURED_BINDINGS` before including 18 | the file. The STL compatibility bits are included as well --- opt-in with 19 | `#define CORRADE_TRIPLE_STL_COMPATIBILITY` before including the file. 20 | Including it multiple times with different macros defined works too. 21 | 22 | v2020.06-1890-g77f9f (2025-04-11) 23 | - NoInit construction now works also with mixed trivial and class types 24 | - Cleanup and unification of SFINAE code 25 | v2020.06-1846-gc4cdf (2025-01-07) 26 | - Non-const C++17 structured bindings are now constexpr as well 27 | - Structured bindings of const types now work even w/o 28 | v2020.06-1687-g6b5f (2024-06-29) 29 | - Added explicit conversion constructors 30 | - Structured bindings on C++17 31 | v2020.06-1502-g147e (2023-09-11) 32 | - Fixes to the Utility::swap() helper to avoid ambiguity with std::swap() 33 | v2020.06-1454-gfc3b7 (2023-08-27) 34 | - Initial release 35 | 36 | Generated from Corrade v2020.06-1890-g77f9f (2025-04-11), 489 / 1769 LoC 37 | */ 38 | 39 | /* 40 | This file is part of Corrade. 41 | 42 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 43 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 44 | Vladimír Vondruš 45 | Copyright © 2022, 2023 Stanislaw Halik 46 | 47 | Permission is hereby granted, free of charge, to any person obtaining a 48 | copy of this software and associated documentation files (the "Software"), 49 | to deal in the Software without restriction, including without limitation 50 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 51 | and/or sell copies of the Software, and to permit persons to whom the 52 | Software is furnished to do so, subject to the following conditions: 53 | 54 | The above copyright notice and this permission notice shall be included 55 | in all copies or substantial portions of the Software. 56 | 57 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 58 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 59 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 60 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 61 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 62 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 63 | DEALINGS IN THE SOFTWARE. 64 | */ 65 | 66 | #include 67 | #include 68 | 69 | #if defined(_MSC_VER) && _MSC_VER < 1910 70 | #define CORRADE_MSVC2015_COMPATIBILITY 71 | #endif 72 | #ifdef __GNUC__ 73 | #define CORRADE_TARGET_GCC 74 | #endif 75 | #ifdef __clang__ 76 | #define CORRADE_TARGET_CLANG 77 | #endif 78 | #ifdef _MSC_VER 79 | #ifdef _MSVC_LANG 80 | #define CORRADE_CXX_STANDARD _MSVC_LANG 81 | #else 82 | #define CORRADE_CXX_STANDARD 201103L 83 | #endif 84 | #else 85 | #define CORRADE_CXX_STANDARD __cplusplus 86 | #endif 87 | 88 | #ifndef Corrade_Tags_h 89 | #define Corrade_Tags_h 90 | 91 | namespace Corrade { 92 | 93 | struct DefaultInitT { 94 | struct Init {}; 95 | constexpr explicit DefaultInitT(Init) {} 96 | }; 97 | 98 | struct ValueInitT { 99 | struct Init {}; 100 | constexpr explicit ValueInitT(Init) {} 101 | }; 102 | 103 | struct NoInitT { 104 | struct Init {}; 105 | constexpr explicit NoInitT(Init) {} 106 | }; 107 | 108 | struct NoCreateT { 109 | struct Init {}; 110 | constexpr explicit NoCreateT(Init) {} 111 | }; 112 | 113 | struct DirectInitT { 114 | struct Init {}; 115 | constexpr explicit DirectInitT(Init) {} 116 | }; 117 | 118 | struct InPlaceInitT { 119 | struct Init {}; 120 | constexpr explicit InPlaceInitT(Init) {} 121 | }; 122 | 123 | constexpr DefaultInitT DefaultInit{DefaultInitT::Init{}}; 124 | 125 | constexpr ValueInitT ValueInit{ValueInitT::Init{}}; 126 | 127 | constexpr NoInitT NoInit{NoInitT::Init{}}; 128 | 129 | constexpr NoCreateT NoCreate{NoCreateT::Init{}}; 130 | 131 | constexpr DirectInitT DirectInit{DirectInitT::Init{}}; 132 | 133 | constexpr InPlaceInitT InPlaceInit{InPlaceInitT::Init{}}; 134 | 135 | } 136 | 137 | #endif 138 | #if CORRADE_CXX_STANDARD >= 201402 && !defined(CORRADE_MSVC2015_COMPATIBILITY) 139 | #define CORRADE_CONSTEXPR14 constexpr 140 | #else 141 | #define CORRADE_CONSTEXPR14 142 | #endif 143 | #ifndef Corrade_Utility_Move_h 144 | #define Corrade_Utility_Move_h 145 | 146 | #ifdef CORRADE_MSVC2015_COMPATIBILITY 147 | #include 148 | #endif 149 | 150 | namespace Corrade { namespace Utility { 151 | 152 | template constexpr T&& forward(typename std::remove_reference::type& t) noexcept { 153 | return static_cast(t); 154 | } 155 | 156 | template constexpr T&& forward(typename std::remove_reference::type&& t) noexcept { 157 | static_assert(!std::is_lvalue_reference::value, "T can't be a lvalue reference"); 158 | return static_cast(t); 159 | } 160 | 161 | template constexpr typename std::remove_reference::type&& move(T&& t) noexcept { 162 | return static_cast::type&&>(t); 163 | } 164 | 165 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 166 | template void swap(T& a, typename std::common_type::type& b) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_move_assignable::value) { 167 | T tmp = static_cast(a); 168 | a = static_cast(b); 169 | b = static_cast(tmp); 170 | } 171 | #else 172 | using std::swap; 173 | #endif 174 | 175 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 176 | template void swap(T(&a)[size], typename std::common_type::type b) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_move_assignable::value) { 177 | for(std::size_t i = 0; i != size; ++i) { 178 | T tmp = static_cast(a[i]); 179 | a[i] = static_cast(b[i]); 180 | b[i] = static_cast(tmp); 181 | } 182 | } 183 | #endif 184 | 185 | }} 186 | 187 | #endif 188 | #ifndef Corrade_Containers_Triple_h 189 | #define Corrade_Containers_Triple_h 190 | 191 | namespace Corrade { namespace Containers { 192 | 193 | namespace Implementation { 194 | template struct TripleConverter; 195 | } 196 | 197 | template class Triple { 198 | static_assert(!std::is_lvalue_reference::value && !std::is_lvalue_reference::value && !std::is_lvalue_reference::value, "use a Reference to store a T& in a Triple"); 199 | 200 | public: 201 | typedef F FirstType; 202 | typedef S SecondType; 203 | typedef T ThirdType; 204 | 205 | #ifndef CORRADE_MSVC2015_COMPATIBILITY 206 | constexpr 207 | #endif 208 | explicit Triple(Corrade::DefaultInitT) noexcept(std::is_nothrow_constructible::value && std::is_nothrow_constructible::value && std::is_nothrow_constructible::value) {} 209 | 210 | constexpr explicit Triple(Corrade::ValueInitT) noexcept(std::is_nothrow_constructible::value && std::is_nothrow_constructible::value && std::is_nothrow_constructible::value): 211 | _first(), _second(), _third() {} 212 | 213 | template::value && std::is_trivial::value && std::is_standard_layout::value && std::is_trivial::value && std::is_standard_layout::value && std::is_trivial::value, int>::type = 0> explicit Triple(Corrade::NoInitT) noexcept {} 214 | template::value && std::is_trivial::value && std::is_standard_layout::value && std::is_trivial::value && std::is_constructible::value, int>::type = 0> explicit Triple(Corrade::NoInitT) noexcept(std::is_nothrow_constructible::value): _third{Corrade::NoInit} {} 215 | template::value && std::is_trivial::value && std::is_constructible::value && std::is_standard_layout::value && std::is_trivial::value, int>::type = 0> explicit Triple(Corrade::NoInitT) noexcept(std::is_nothrow_constructible::value): _second{Corrade::NoInit} {} 216 | template::value && std::is_standard_layout::value && std::is_trivial::value && std::is_standard_layout::value && std::is_trivial::value, int>::type = 0> explicit Triple(Corrade::NoInitT) noexcept(std::is_nothrow_constructible::value): _first{Corrade::NoInit} {} 217 | template::value && std::is_trivial::value && std::is_constructible::value && std::is_constructible::value, int>::type = 0> explicit Triple(Corrade::NoInitT) noexcept(std::is_nothrow_constructible::value && std::is_nothrow_constructible::value): _second{Corrade::NoInit}, _third{Corrade::NoInit} {} 218 | template::value && std::is_standard_layout::value && std::is_trivial::value && std::is_constructible::value, int>::type = 0> explicit Triple(Corrade::NoInitT) noexcept(std::is_nothrow_constructible::value && std::is_nothrow_constructible::value): _first{Corrade::NoInit}, _third{Corrade::NoInit} {} 219 | template::value && std::is_constructible::value && std::is_standard_layout::value && std::is_trivial::value, int>::type = 0> explicit Triple(Corrade::NoInitT) noexcept(std::is_nothrow_constructible::value && std::is_nothrow_constructible::value): _first{Corrade::NoInit}, _second{Corrade::NoInit} {} 220 | template::value && std::is_constructible::value && std::is_constructible::value, int>::type = 0> explicit Triple(Corrade::NoInitT) noexcept(std::is_nothrow_constructible::value && std::is_nothrow_constructible::value && std::is_nothrow_constructible::value): _first{Corrade::NoInit}, _second{Corrade::NoInit}, _third{Corrade::NoInit} {} 221 | 222 | constexpr /*implicit*/ Triple() noexcept(std::is_nothrow_constructible::value && std::is_nothrow_constructible::value && std::is_nothrow_constructible::value): 223 | #ifdef CORRADE_MSVC2015_COMPATIBILITY 224 | _first{}, _second{}, _third{} 225 | #else 226 | Triple{Corrade::ValueInit} 227 | #endif 228 | {} 229 | 230 | constexpr /*implicit*/ Triple(const F& first, const S& second, const T& third) noexcept(std::is_nothrow_copy_constructible::value && std::is_nothrow_copy_constructible::value && std::is_nothrow_copy_constructible::value): 231 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 232 | _first(first), _second(second), _third(third) 233 | #else 234 | _first{first}, _second{second}, _third{third} 235 | #endif 236 | {} 237 | constexpr /*implicit*/ Triple(const F& first, const S& second, T&& third) noexcept(std::is_nothrow_copy_constructible::value && std::is_nothrow_copy_constructible::value && std::is_nothrow_move_constructible::value): 238 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 239 | _first(first), _second(second), _third(Utility::move(third)) 240 | #else 241 | _first{first}, _second{second}, _third{Utility::move(third)} 242 | #endif 243 | {} 244 | constexpr /*implicit*/ Triple(const F& first, S&& second, const T& third) noexcept(std::is_nothrow_copy_constructible::value && std::is_nothrow_move_constructible::value && std::is_nothrow_copy_constructible::value): 245 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 246 | _first(first), _second(Utility::move(second)), _third(third) 247 | #else 248 | _first{first}, _second{Utility::move(second)}, _third{third} 249 | #endif 250 | {} 251 | constexpr /*implicit*/ Triple(F&& first, const S& second, const T& third) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_copy_constructible::value && std::is_nothrow_copy_constructible::value): 252 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 253 | _first(Utility::move(first)), _second(second), _third(third) 254 | #else 255 | _first{Utility::move(first)}, _second{second}, _third{third} 256 | #endif 257 | {} 258 | constexpr /*implicit*/ Triple(const F& first, S&& second, T&& third) noexcept(std::is_nothrow_copy_constructible::value && std::is_nothrow_move_constructible::value && std::is_nothrow_move_constructible::value): 259 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 260 | _first(first), _second(Utility::move(second)), _third(Utility::move(third)) 261 | #else 262 | _first{first}, _second{Utility::move(second)}, _third{Utility::move(third)} 263 | #endif 264 | {} 265 | constexpr /*implicit*/ Triple(F&& first, const S& second, T&& third) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_copy_constructible::value && std::is_nothrow_move_constructible::value): 266 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 267 | _first(Utility::move(first)), _second(second), _third(Utility::move(third)) 268 | #else 269 | _first{Utility::move(first)}, _second{second}, _third{Utility::move(third)} 270 | #endif 271 | {} 272 | constexpr /*implicit*/ Triple(F&& first, S&& second, const T& third) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_move_constructible::value && std::is_nothrow_copy_constructible::value): 273 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 274 | _first(Utility::move(first)), _second(Utility::move(second)), _third(third) 275 | #else 276 | _first{Utility::move(first)}, _second{Utility::move(second)}, _third{third} 277 | #endif 278 | {} 279 | constexpr /*implicit*/ Triple(F&& first, S&& second, T&& third) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_move_constructible::value && std::is_nothrow_move_constructible::value): 280 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 281 | _first(Utility::move(first)), _second(Utility::move(second)), _third(Utility::move(third)) 282 | #else 283 | _first{Utility::move(first)}, _second{Utility::move(second)}, _third{Utility::move(third)} 284 | #endif 285 | {} 286 | 287 | template::value && std::is_constructible::value && std::is_constructible::value, int>::type = 0 289 | > constexpr explicit Triple(const Triple& other) noexcept(std::is_nothrow_constructible::value && std::is_nothrow_constructible::value && std::is_nothrow_constructible::value): 290 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 291 | _first(F(other._first)), _second(S(other._second)), _third(T(other._third)) 292 | #else 293 | _first{F(other._first)}, _second{S(other._second)}, _third{T(other._third)} 294 | #endif 295 | {} 296 | 297 | template::value && std::is_constructible::value && std::is_constructible::value, int>::type = 0 299 | > constexpr explicit Triple(Triple&& other) noexcept(std::is_nothrow_constructible::value && std::is_nothrow_constructible::value && std::is_nothrow_constructible::value): 300 | #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5 301 | _first(F(Utility::move(other._first))), _second(S(Utility::move(other._second))), _third(T(Utility::move(other._third))) 302 | #else 303 | _first{F(Utility::move(other._first))}, _second{S(Utility::move(other._second))}, _third{T(Utility::move(other._third))} 304 | #endif 305 | {} 306 | 307 | template::from(std::declval()))> /*implicit*/ Triple(const U& other) noexcept(std::is_nothrow_copy_constructible::value && std::is_nothrow_copy_constructible::value && std::is_nothrow_copy_constructible::value): Triple{Implementation::TripleConverter::from(other)} {} 308 | 309 | template::from(std::declval()))> /*implicit*/ Triple(U&& other) noexcept(std::is_nothrow_move_constructible::value && std::is_nothrow_move_constructible::value && std::is_nothrow_move_constructible::value): Triple{Implementation::TripleConverter::from(Utility::move(other))} {} 310 | 311 | template::to(std::declval&>()))> /*implicit*/ operator U() const & { 312 | return Implementation::TripleConverter::to(*this); 313 | } 314 | 315 | template::to(std::declval&&>()))> /*implicit*/ operator U() && { 316 | return Implementation::TripleConverter::to(Utility::move(*this)); 317 | } 318 | 319 | constexpr bool operator==(const Triple& other) const { 320 | return _first == other._first && _second == other._second && _third == other._third; 321 | } 322 | 323 | constexpr bool operator!=(const Triple& other) const { 324 | return !operator==(other); 325 | } 326 | 327 | CORRADE_CONSTEXPR14 F& first() & { return _first; } 328 | CORRADE_CONSTEXPR14 F first() && { return Utility::move(_first); } 329 | constexpr const F& first() const & { return _first; } 330 | 331 | CORRADE_CONSTEXPR14 S& second() & { return _second; } 332 | CORRADE_CONSTEXPR14 S second() && { return Utility::move(_second); } 333 | constexpr const S& second() const & { return _second; } 334 | 335 | CORRADE_CONSTEXPR14 T& third() & { return _third; } 336 | CORRADE_CONSTEXPR14 T third() && { return Utility::move(_third); } 337 | constexpr const T& third() const & { return _third; } 338 | 339 | private: 340 | template friend class Triple; 341 | 342 | #if CORRADE_CXX_STANDARD > 201402 343 | template::type = 0> constexpr friend const F& get(const Triple& value) { 344 | return value._first; 345 | } 346 | template::type = 0> CORRADE_CONSTEXPR14 friend F& get(Triple& value) { 347 | return value._first; 348 | } 349 | template::type = 0> CORRADE_CONSTEXPR14 friend F&& get(Triple&& value) { 350 | return Utility::move(value._first); 351 | } 352 | template::type = 0> constexpr friend const S& get(const Triple& value) { 353 | return value._second; 354 | } 355 | template::type = 0> CORRADE_CONSTEXPR14 friend S& get(Triple& value) { 356 | return value._second; 357 | } 358 | template::type = 0> CORRADE_CONSTEXPR14 friend S&& get(Triple&& value) { 359 | return Utility::move(value._second); 360 | } 361 | template::type = 0> constexpr friend const T& get(const Triple& value) { 362 | return value._third; 363 | } 364 | template::type = 0> CORRADE_CONSTEXPR14 friend T& get(Triple& value) { 365 | return value._third; 366 | } 367 | template::type = 0> CORRADE_CONSTEXPR14 friend T&& get(Triple&& value) { 368 | return Utility::move(value._third); 369 | } 370 | #endif 371 | 372 | F _first; 373 | S _second; 374 | T _third; 375 | }; 376 | 377 | template constexpr Triple::type, typename std::decay::type, typename std::decay::type> triple(F&& first, S&& second, T&& third) { 378 | return Triple::type, typename std::decay::type, typename std::decay::type>{Utility::forward(first), Utility::forward(second), Utility::forward(third)}; 379 | } 380 | 381 | namespace Implementation { 382 | template struct DeducedTripleConverter; 383 | } 384 | 385 | template inline auto triple(T&& other) -> decltype(Implementation::DeducedTripleConverter::type>::from(Utility::forward(other))) { 386 | return Implementation::DeducedTripleConverter::type>::from(Utility::forward(other)); 387 | } 388 | 389 | }} 390 | 391 | #endif 392 | #ifdef CORRADE_TRIPLE_STL_COMPATIBILITY 393 | #include 394 | #ifndef Corrade_Containers_TripleStl_h 395 | #define Corrade_Containers_TripleStl_h 396 | 397 | namespace Corrade { namespace Containers { namespace Implementation { 398 | 399 | template struct TripleConverter> { 400 | static Triple from(const std::tuple& other) { 401 | return {std::get<0>(other), std::get<1>(other), std::get<2>(other)}; 402 | } 403 | 404 | static Triple from(std::tuple&& other) { 405 | return {Utility::move(std::get<0>(other)), Utility::move(std::get<1>(other)), Utility::move(std::get<2>(other))}; 406 | } 407 | 408 | static std::tuple to(const Triple& other) { 409 | return std::tuple{other.first(), other.second(), other.third()}; 410 | } 411 | 412 | static std::tuple to(Triple&& other) { 413 | return std::tuple{Utility::move(other.first()), Utility::move(other.second()), Utility::move(other.third())}; 414 | } 415 | }; 416 | 417 | template struct DeducedTripleConverter>: TripleConverter> {}; 418 | 419 | }}} 420 | 421 | #endif 422 | #endif 423 | #ifdef CORRADE_STRUCTURED_BINDINGS 424 | #if CORRADE_CXX_STANDARD >= 202002 425 | #include 426 | #else 427 | #include 428 | #endif 429 | #ifdef _LIBCPP_VERSION 430 | #define CORRADE_TARGET_LIBCXX 431 | #elif defined(_CPPLIB_VER) 432 | #define CORRADE_TARGET_DINKUMWARE 433 | #elif defined(__GLIBCXX__) 434 | #define CORRADE_TARGET_LIBSTDCXX 435 | #elif defined(__has_include) 436 | #if __has_include() 437 | #include 438 | #ifdef __GLIBCXX__ 439 | #define CORRADE_TARGET_LIBSTDCXX 440 | #endif 441 | #endif 442 | #elif defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5 443 | #define CORRADE_TARGET_LIBSTDCXX 444 | #else 445 | #endif 446 | #ifndef Corrade_Utility_StlForwardTupleSizeElement_h 447 | #define Corrade_Utility_StlForwardTupleSizeElement_h 448 | 449 | #ifdef CORRADE_TARGET_LIBCXX 450 | _LIBCPP_BEGIN_NAMESPACE_STD 451 | #elif defined(CORRADE_TARGET_LIBSTDCXX) 452 | #include 453 | namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION 454 | #elif defined(CORRADE_TARGET_DINKUMWARE) 455 | _STD_BEGIN 456 | #endif 457 | 458 | #if defined(CORRADE_TARGET_LIBCXX) || defined(CORRADE_TARGET_LIBSTDCXX) || defined(CORRADE_TARGET_DINKUMWARE) 459 | template struct tuple_element; 460 | template struct tuple_size; 461 | #else 462 | #include 463 | #endif 464 | 465 | #ifdef CORRADE_TARGET_LIBCXX 466 | _LIBCPP_END_NAMESPACE_STD 467 | #elif defined(CORRADE_TARGET_LIBSTDCXX) 468 | _GLIBCXX_END_NAMESPACE_VERSION } 469 | #elif defined CORRADE_TARGET_MSVC 470 | _STD_END 471 | #endif 472 | 473 | #endif 474 | namespace std { 475 | 476 | #ifndef Corrade_Containers_StructuredBindings_Triple_h 477 | #define Corrade_Containers_StructuredBindings_Triple_h 478 | template struct tuple_size>: integral_constant {}; 479 | template struct tuple_size>: integral_constant {}; 480 | template struct tuple_element<0, Corrade::Containers::Triple> { typedef F type; }; 481 | template struct tuple_element<1, Corrade::Containers::Triple> { typedef S type; }; 482 | template struct tuple_element<2, Corrade::Containers::Triple> { typedef T type; }; 483 | template struct tuple_element> { 484 | typedef const typename tuple_element>::type type; 485 | }; 486 | #endif 487 | 488 | } 489 | #endif 490 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This repository contains single-header libraries from the Magnum engine. 2 | 3 | [![Join the chat at https://gitter.im/mosra/magnum](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mosra/magnum?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 4 | [![Build Status](https://circleci.com/gh/mosra/magnum-singles.svg?style=shield)](https://circleci.com/gh/mosra/magnum-singles) 5 | [![MIT License](https://img.shields.io/badge/license-MIT-green.svg)](https://opensource.org/licenses/MIT) 6 | 7 | - Project homepage — https://magnum.graphics/ 8 | - Documentation — https://doc.magnum.graphics/ 9 | - GitHub project page — https://github.com/mosra/magnum-singles 10 | 11 | LIBRARIES 12 | ========= 13 | 14 | There are the following single-header libraries at the moment. This list will 15 | grow with more Magnum features being exposed this way. 16 | 17 | Library | LoC | PpLoC[1] | Description 18 | --------------- | --- | ----------------------- | ------------------- 19 | **[CorradeArrayView.h](CorradeArrayView.h)** | 927 | 2031 | [Containers::ArrayView](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1ArrayView.html) and [Containers::StaticArrayView](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1StaticArrayView.html), lightweight alternatives to [`std::span`](https://en.cppreference.com/w/cpp/container/span) 20 | **[CorradeStridedArrayView.h](CorradeStridedArrayView.h)** | 1415[2] | 2906 | [Containers::StridedArrayView](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1StridedArrayView.html), multi-dimensional strided array view. Depends on `CorradeArrayView.h`. 21 | **[CorradeArray.h](CorradeArray.h)** | 1067[2] | 2733 | [Containers::Array](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1Array.html) and [Containers::StaticArray](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1StaticArray.html), lightweight alternatives to [`std::vector`](https://en.cppreference.com/w/cpp/container/vector) and [`std::array`](https://en.cppreference.com/w/cpp/container/span). Depends on `CorradeArrayView.h`. 22 | **[CorradeGrowableArray.h](CorradeGrowableArray.h)** | 1126[2] | 4334 | Growable APIs for [Containers::Array](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1Array.html#Containers-Array-growable). Depends on `CorradeArray.h`. 23 | **[CorradeEnumSet.h](CorradeEnumSet.h)** | 269 | 1703 | [Containers::EnumSet](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1EnumSet.html), a type-safe set of bits 24 | **[CorradeFunction.h](CorradeFunction.h)** | 505 | 1907 | [Containers::Function](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1Function_3_01R_07Args_8_8_8_08_4.html), a lightweight alternative to [`std::function`](https://en.cppreference.com/w/cpp/utility/functional/function) 25 | **[CorradeOptional.h](CorradeOptional.h)** | 458 | 1863 | [Containers::Optional](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1Optional.html), a lightweight alternative to [`std::optional`](https://en.cppreference.com/w/cpp/utility/optional) 26 | **[CorradePair.h](CorradePair.h)** | 441 | 1748 | [Containers::Pair](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1Pair.html), a lightweight alternative to [`std::pair`](https://en.cppreference.com/w/cpp/utility/pair) 27 | **[CorradePointer.h](CorradePointer.h)** | 384 | 1784 | [Containers::Pointer](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1Pointer.html), a lightweight alternative to [`std::unique_ptr`](https://en.cppreference.com/w/cpp/memory/unique_ptr) 28 | **[CorradeReference.h](CorradeReference.h)** | 135 | 1628 | [Containers::Reference](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1Reference.html), a lightweight alternative to [`std::reference_wrapper`](https://en.cppreference.com/w/cpp/utility/functional/reference_wrapper) 29 | **[CorradeScopeGuard.h](CorradeScopeGuard.h)** | 263 | 1689 | [Containers::ScopeGuard](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1ScopeGuard.html), a lightweight alternative to [`std::unique_ptr`](https://en.cppreference.com/w/cpp/memory/unique_ptr) with a custom deleter 30 | **[CorradeString.hpp](CorradeString.hpp)** | 2530[2] | 2198 | [Containers::String](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1String.html) and [Containers::StringView](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1BasicStringView.html), lightweight and optimized string (view) classes. Depends on `CorradeEnumSet.h`, the implementation depends on `CorradeCpu.hpp`. 31 | **[CorradeTriple.h](CorradeTriple.h)** | 489 | 1769 | [Containers::Triple](https://doc.magnum.graphics/corrade/classCorrade_1_1Containers_1_1Triple.html), a lightweight alternative to a three-component [`std::tuple`](https://en.cppreference.com/w/cpp/utility/tuple) 32 | **[CorradeCpu.hpp](CorradeCpu.hpp)** | 1733 | 1991 | [Cpu](https://doc.magnum.graphics/corrade/namespaceCorrade_1_1Cpu.html) library, compile-time and runtime CPU feature detection and dispatch 33 | **[CorradeStlForwardArray.h](CorradeStlForwardArray.h)** | 88 | 99[3] | [Corrade's forward declaration for `std::array`](https://doc.magnum.graphics/corrade/StlForwardArray_8h.html), a lightweight alternative to the full [``](https://en.cppreference.com/w/cpp/header/array) (15k PpLOC[1]) where supported 34 | **[CorradeStlForwardString.h](CorradeStlForwardString.h)** | 89 | 92 | [Corrade's forward declaration for `std::string`](https://doc.magnum.graphics/corrade/StlForwardString_8h.html), a lightweight alternative to the full [``](https://en.cppreference.com/w/cpp/header/string) (11k PpLOC[1]) where supported 35 | **[CorradeStlForwardTuple.h](CorradeStlForwardTuple.h)** | 102 | 2231 | [Corrade's forward declaration for `std::tuple`](https://doc.magnum.graphics/corrade/StlForwardTuple_8h.html), a lightweight alternative to the full [``](https://en.cppreference.com/w/cpp/header/tuple) (13k PpLOC[1]) where supported 36 | **[CorradeStlForwardVector.h](CorradeStlForwardVector.h)** | 81 | 181[3] | [Corrade's forward declaration for `std::vector`](https://doc.magnum.graphics/corrade/StlForwardVector_8h.html), a lightweight alternative to the full [``](https://en.cppreference.com/w/cpp/header/tuple) (9k PpLOC[1]) where supported 37 | **[CorradeStlMath.h](CorradeStlMath.h)** | 73 | 3301[4] | [Corrade's optimized ``](https://doc.magnum.graphics/corrade/StlMath_8h.html), without the heavy C++17 additions (which is otherwise 11k PpLOC[4]) 38 | **[MagnumMath.hpp](MagnumMath.hpp)** | 8496[2] | 9985 | [Math](https://doc.magnum.graphics/magnum/namespaceMagnum_1_1Math.html) namespace, a full-featured graphics-oriented linear algebra library. Depends on `CorradePair.h`. 39 | **[MagnumMathBatch.hpp](MagnumMathBatch.hpp)** | 1323[2] | 11405 | [Math](https://doc.magnum.graphics/magnum/namespaceMagnum_1_1Math.html) namespace, batch APIs. The implementation depends on `CorradeStridedArrayView.h` and `MagnumMath.hpp`. 40 | **[MagnumMeshTools.hpp](MagnumMeshTools.hpp)** | 768[2] | 283 | [MeshTools](https://doc.magnum.graphics/magnum/namespaceMagnum_1_1MeshTools.html) namespace, algorithms for dealing with mesh data. Depends on `CorradeStridedArrayView.h`, the implementation depends on `CorradeArray.h` and `MagnumMathBatch.hpp`. 41 | 42 | [1] — lines of code after a preprocessor run, with system includes 43 | expanded. Gathered using GCC 14.2 and libstdc++, unless said otherwise. 44 | 45 | [2] — not a total size due to inter-library dependencies 46 | 47 | [3] — gathered using Clang 18.1 and libc++, since libstdc++ doesn't 48 | have a forward declaration for `std::array` / `std::vector` 49 | 50 | [4] — gathered using GCC 14.2, libstdc++ and `-std=c++17` 51 | 52 | Where is the documentation? 53 | --------------------------- 54 | 55 | Single-header libraries provided here are *generated* from multi-file sources 56 | in the Magnum project. This is done for two reasons — first, documentation and 57 | test coverage is much easier to maintain in the setting of a bigger project, 58 | avoiding any redundancy or duplicated efforts. Second, because the resulting 59 | files are generated with non-essential parts stripped away, there's no need to 60 | worry about bloating them due to original implementations having extensive 61 | documentation or rarely used features. 62 | 63 | With the goal being easy integration, the files are deliberately free of all 64 | comments and documentation blocks to keep their size small. Documentation for 65 | each library is provided in the official Magnum documentation, linked from the 66 | table above. Each library file contains the same documentation link, together 67 | with a concrete Git revision it was generated from and a changelog for a few 68 | versions back for easier overview when updating. 69 | 70 | For more information read the [single-header library docs](https://doc.magnum.graphics/corrade/corrade-singles.html). The libraries are generated 71 | using `acme.py`, which is a part of Corrade. 72 | [See its documentation](https://doc.magnum.graphics/corrade/acme.html), if you 73 | are interested. Particular libraries are introduced on the Magnum blog: 74 | 75 | - [Lightweight but still STL-compatible unique pointer](https://blog.magnum.graphics/backstage/lightweight-stl-compatible-unique-pointer/) 76 | (Jan 16, 2019) 77 | - [Array view implementations in Magnum](https://blog.magnum.graphics/backstage/array-view-implementations/) 78 | (Feb 18, 2019) 79 | - [Forward-declaring STL container types](https://blog.magnum.graphics/backstage/forward-declaring-stl-container-types/) 80 | (Mar 28, 2019) 81 | - [Multi-dimensional strided array views in Magnum](https://blog.magnum.graphics/backstage/multidimensional-strided-array-views/) 82 | (Apr 30, 2019) 83 | - [Convenient CPU feature detection and dispatch](https://blog.magnum.graphics/backstage/cpu-feature-detection-dispatch/) 84 | (Aug 2, 2022) 85 | 86 | What about test coverage? 87 | ------------------------- 88 | 89 | Testing done in this repository is mainly to ensure the libraries are generated 90 | correctly. Extensive testing on variety of compilers and OSes with > 99% test 91 | coverage is done in the Magnum Project itself. See the 92 | [Build Status](https://magnum.graphics/build-status/) page for more 93 | information. 94 | 95 | Reporting bugs and contributing 96 | ------------------------------- 97 | 98 | As always, bug reports, feature requests and code contributions are very 99 | welcome. However again please note the files in this repository are generated 100 | from original sources in the [corrade](https://github.com/mosra/corrade) and 101 | [magnum](https://github.com/mosra/magnum) repositories, meaning that ideally 102 | all PRs should go there instead, as there's a better infrastructure for 103 | documentation and testing. We don't enforce this rule though — if you have an 104 | important bugfix, it's better if you submit it here than not at all 😉 105 | 106 | SUPPORTED PLATFORMS 107 | =================== 108 | 109 | All libraries are tested on these platforms: 110 | 111 | - **Linux** and embedded Linux 112 | - **Windows**, **Windows RT** (Store/Phone) 113 | - **macOS**, **iOS** 114 | - **Android** 115 | - **Web** ([asm.js](http://asmjs.org/) or [WebAssembly](http://webassembly.org/)), 116 | through [Emscripten](http://kripken.github.io/emscripten-site/) 117 | 118 | And on these compilers: 119 | 120 | - **GCC** 4.8.1 and newer (and equivalent MinGW-w64 version) 121 | - **Clang** 6.0 and newer (or AppleClang 10.0 and newer), both `libstdc++` 122 | and `libc++` 123 | - **MSVC** 2015 and newer 124 | 125 | CONTACT & SUPPORT 126 | ================= 127 | 128 | - Project homepage — https://magnum.graphics/ 129 | - Documentation — https://doc.magnum.graphics/ 130 | - GitHub — https://github.com/mosra/magnum-singles and the 131 | [#magnum](https://github.com/topics/magnum) topic 132 | - GitLab — https://gitlab.com/mosra/magnum-singles 133 | - Gitter community chat — https://gitter.im/mosra/magnum 134 | - E-mail — info@magnum.graphics 135 | - Google Groups mailing list — magnum-engine@googlegroups.com 136 | ([archive](https://groups.google.com/forum/#!forum/magnum-engine)) 137 | - Bluesky — https://bsky.app/profile/mosra.cz 138 | 139 | See also the Magnum Project [Contact & Support page](https://magnum.graphics/contact/) 140 | for further information. 141 | 142 | Credits 143 | ------- 144 | 145 | Libraries presented here are a result of a dedicated work by many community 146 | members. List of all contributors to the Magnum Project can be found 147 | [in the documentation](https://doc.magnum.graphics/magnum/credits-contributors.html). 148 | 149 | License 150 | ------- 151 | 152 | Magnum is licensed under the MIT/Expat license, see the [COPYING](COPYING) file 153 | for details. 154 | -------------------------------------------------------------------------------- /package/ci/circleci.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | executors: 4 | ubuntu-18_04: 5 | docker: 6 | - image: ubuntu:bionic-20220427 7 | 8 | commands: 9 | install-base-linux: 10 | parameters: 11 | extra: 12 | type: string 13 | steps: 14 | - run: 15 | name: Update apt and install base packages 16 | command: | 17 | apt update 18 | apt install -y git << parameters.extra >> 19 | 20 | install-gcc-4_8: 21 | steps: 22 | - run: 23 | name: Install GCC 4.8 24 | # For some reason, CMake needs a working C compiler, so provice CC as 25 | # well for the case when default gcc isn't installed. 26 | command: | 27 | apt install -y g++-4.8 28 | echo 'export CC=gcc-4.8' >> $BASH_ENV 29 | echo 'export CXX=g++-4.8' >> $BASH_ENV 30 | 31 | jobs: 32 | linux: 33 | executor: ubuntu-18_04 34 | steps: 35 | - install-base-linux: 36 | # heh 37 | extra: time 38 | - install-gcc-4_8 39 | - checkout 40 | - run: 41 | # TODO add testing of C++17, C++20 features once such compiler is here 42 | # TODO test growable array sanitizer annotations on a compiler that 43 | # actually has __sanitizer_annotate_contiguous_container 44 | # TODO test also Math GLM and Eigen opt-in 45 | name: Build all singles 46 | command: | 47 | export COMPILE="time g++-4.8 -std=c++11 -Wall -Wextra -pedantic" 48 | 49 | cd test 50 | 51 | # First page in the compiler so the following measurements are less wild 52 | echo "int main() {}" | $COMPILE -x c++ - && ./a.out 53 | 54 | $COMPILE CorradeArrayView.cpp 55 | ./a.out 56 | $COMPILE CorradeArrayView.cpp -DCORRADE_ARRAYVIEW_STL_COMPATIBILITY 57 | ./a.out 58 | $COMPILE CorradeStridedArrayView.cpp 59 | ./a.out 60 | $COMPILE CorradeArray.cpp 61 | ./a.out 62 | $COMPILE CorradeGrowableArray.cpp 63 | ./a.out 64 | $COMPILE CorradeGrowableArray.cpp -fsanitize=address -DCORRADE_CONTAINERS_NO_SANITIZER_ANNOTATIONS 65 | ./a.out 66 | $COMPILE CorradeEnumSet.cpp 67 | ./a.out 68 | $COMPILE CorradeFunction.cpp 69 | ./a.out 70 | $COMPILE CorradeOptional.cpp 71 | ./a.out 72 | $COMPILE CorradePair.cpp 73 | ./a.out 74 | $COMPILE CorradePair.cpp -DCORRADE_PAIR_STL_COMPATIBILITY 75 | ./a.out 76 | $COMPILE CorradePointer.cpp 77 | ./a.out 78 | $COMPILE CorradePointer.cpp -DCORRADE_POINTER_STL_COMPATIBILITY 79 | ./a.out 80 | $COMPILE CorradeReference.cpp 81 | ./a.out 82 | $COMPILE CorradeReference.cpp -DCORRADE_REFERENCE_STL_COMPATIBILITY 83 | ./a.out 84 | $COMPILE CorradeScopeGuard.cpp 85 | ./a.out 86 | $COMPILE CorradeString.cpp 87 | ./a.out 88 | $COMPILE CorradeString.cpp -DCORRADE_STRING_STL_COMPATIBILITY 89 | ./a.out 90 | $COMPILE CorradeString.cpp -DCORRADE_NO_CPU_RUNTIME_DISPATCH 91 | ./a.out 92 | $COMPILE CorradeString.cpp -DCORRADE_CPU_USE_IFUNC 93 | ./a.out 94 | $COMPILE CorradeTriple.cpp 95 | ./a.out 96 | $COMPILE CorradeTriple.cpp -DCORRADE_TRIPLE_STL_COMPATIBILITY 97 | ./a.out 98 | $COMPILE CorradeStlForwardArray.cpp 99 | ./a.out 100 | $COMPILE CorradeStlForwardString.cpp 101 | ./a.out 102 | $COMPILE CorradeStlForwardTuple.cpp 103 | ./a.out 104 | $COMPILE CorradeStlForwardVector.cpp 105 | ./a.out 106 | $COMPILE CorradeStlMath.cpp 107 | ./a.out 108 | $COMPILE CorradeCpu.cpp 109 | ./a.out 110 | $COMPILE CorradeCpu.cpp -DCORRADE_CPU_USE_IFUNC 111 | ./a.out 112 | $COMPILE MagnumMath.cpp 113 | ./a.out 114 | $COMPILE MagnumMath.cpp -DMAGNUM_MATH_STL_COMPATIBILITY 115 | ./a.out 116 | $COMPILE MagnumMathBatch.cpp 117 | ./a.out 118 | $COMPILE MagnumMeshTools.cpp 119 | ./a.out 120 | 121 | workflows: 122 | version: 2 123 | build: 124 | jobs: 125 | - linux 126 | -------------------------------------------------------------------------------- /package/generate-loc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | dir=$(dirname "$0") 6 | 7 | for i in $(ls $dir/../*.{h,hpp}); do 8 | echo "**[$i]($i)** |" $(cat $i | wc -l) '|' $(echo "#include \"$i\"" | g++ -std=c++11 -P -E -x c++ - | wc -l) 9 | done 10 | -------------------------------------------------------------------------------- /test/CorradeArray.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Corrade. 3 | 4 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 5 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 6 | Vladimír Vondruš 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #include "../CorradeArray.h" 28 | /* Including second time to verify some symbols don't get accidentally defined 29 | twice due to missing include guards. Mainly important for files that have an 30 | implementation part, but doesn't hurt to test for all. */ 31 | #include "../CorradeArray.h" 32 | 33 | using namespace Corrade; 34 | 35 | /* 36 | Does this look funny? That's DEFINITELY NOT how testing should look, right? 37 | True dat. The actual tests, with >99% code coverage, are done in the Magnum 38 | project itself, because there's much better tooling for that. Have a look: 39 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/ArrayTest.cpp 40 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/ArrayStlSpanTest.cpp 41 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/StaticArrayTest.cpp 42 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/StaticArrayStlSpanTest.cpp 43 | */ 44 | 45 | int main() { 46 | Containers::Array a{InPlaceInit, {1, 3, 42, 1337}}; 47 | Containers::StaticArray<1, int> b{42}; 48 | return a.slice<1>(2)[0] - *b; 49 | } 50 | -------------------------------------------------------------------------------- /test/CorradeArrayView.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Corrade. 3 | 4 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 5 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 6 | Vladimír Vondruš 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #include "../CorradeArrayView.h" 28 | /* Including second time to verify some symbols don't get accidentally defined 29 | twice due to missing include guards. Mainly important for files that have an 30 | implementation part, but doesn't hurt to test for all. */ 31 | #include "../CorradeArrayView.h" 32 | 33 | using namespace Corrade; 34 | 35 | /* 36 | Does this look funny? That's DEFINITELY NOT how testing should look, right? 37 | True dat. The actual tests, with >99% code coverage, are done in the Magnum 38 | project itself, because there's much better tooling for that. Have a look: 39 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/ArrayViewTest.cpp 40 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/ArrayViewStlTest.cpp 41 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/ArrayViewStlSpanTest.cpp 42 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/StaticArrayViewTest.cpp 43 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/StaticArrayViewStlTest.cpp 44 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/StaticArrayViewStlSpanTest.cpp 45 | */ 46 | 47 | int main() { 48 | #ifndef CORRADE_ARRAYVIEW_STL_COMPATIBILITY 49 | int data[]{1, 3, 42, 1337}; 50 | #else 51 | std::array data{{1, 3, 42, 1337}}; 52 | #endif 53 | 54 | auto a = Containers::arrayView(data); 55 | Containers::StaticArrayView<1, int> b = a.slice<1>(2); 56 | return *b - 42; 57 | } 58 | -------------------------------------------------------------------------------- /test/CorradeCpu.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Corrade. 3 | 4 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 5 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 6 | Vladimír Vondruš 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #define CORRADE_CPU_IMPLEMENTATION 28 | #include "../CorradeCpu.hpp" 29 | /* Including second time to verify the implementation (or other) symbols don't 30 | get accidentally defined twice. See comment in the input file for details 31 | how this can happen in practice. */ 32 | #include "../CorradeCpu.hpp" 33 | 34 | using namespace Corrade; 35 | 36 | /* 37 | Does this look funny? That's DEFINITELY NOT how testing should look, right? 38 | True dat. The actual tests, with >99% code coverage, are done in the Magnum 39 | project itself, because there's much better tooling for that. Have a look: 40 | https://github.com/mosra/corrade/blob/master/src/Corrade/Test/CpuTest.cpp 41 | */ 42 | 43 | auto fooImplementation(Cpu::ScalarT) -> int(*)() { return []() { return 42; }; } 44 | #ifdef CORRADE_TARGET_X86 45 | auto fooImplementation(Cpu::AvxT) -> int(*)() { return []() { return 42; }; } 46 | #elif defined(CORRADE_TARGET_ARM) 47 | auto fooImplementation(Cpu::NeonT) -> int(*)() { return []() { return 42; }; } 48 | #elif defined(CORRADE_TARGET_WASM) 49 | auto fooImplementation(Cpu::Simd128T) -> int(*)() { return []() { return 42; }; } 50 | #endif 51 | 52 | CORRADE_CPU_DISPATCHER_BASE(fooImplementation) 53 | #ifdef CORRADE_CPU_USE_IFUNC 54 | CORRADE_CPU_DISPATCHED_IFUNC(fooImplementation, int foo()) 55 | #else 56 | CORRADE_CPU_DISPATCHED_POINTER(fooImplementation, int (*foo)()) 57 | #endif 58 | 59 | int main() { 60 | /* CORRADE_CPU_IMPLEMENTATION has code only on ARM and Apple, and it's 61 | executed as part of the dispatch */ 62 | return foo() - 42; 63 | } 64 | -------------------------------------------------------------------------------- /test/CorradeEnumSet.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Corrade. 3 | 4 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 5 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 6 | Vladimír Vondruš 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #include "../CorradeEnumSet.h" 28 | /* Including second time to verify some symbols don't get accidentally defined 29 | twice due to missing include guards. Mainly important for files that have an 30 | implementation part, but doesn't hurt to test for all. */ 31 | #include "../CorradeEnumSet.h" 32 | 33 | using namespace Corrade; 34 | 35 | /* 36 | Does this look funny? That's DEFINITELY NOT how testing should look, right? 37 | True dat. The actual tests, with >99% code coverage, are done in the Magnum 38 | project itself, because there's much better tooling for that. Have a look: 39 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/EnumSetTest.cpp 40 | */ 41 | 42 | enum class Foo { 43 | One = 1 << 0, 44 | Two = 1 << 1 45 | }; 46 | 47 | typedef Containers::EnumSet Foos; 48 | CORRADE_ENUMSET_OPERATORS(Foos) 49 | 50 | int main() { 51 | Foos a = Foo::One|Foo::Two; 52 | return Containers::enumCastUnderlyingType(a) - 3; 53 | } 54 | -------------------------------------------------------------------------------- /test/CorradeFunction.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Corrade. 3 | 4 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 5 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 6 | Vladimír Vondruš 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #include "../CorradeFunction.h" 28 | /* Including second time to verify some symbols don't get accidentally defined 29 | twice due to missing include guards. Mainly important for files that have an 30 | implementation part, but doesn't hurt to test for all. */ 31 | #include "../CorradeFunction.h" 32 | 33 | using namespace Corrade; 34 | 35 | /* 36 | Does this look funny? That's DEFINITELY NOT how testing should look, right? 37 | True dat. The actual tests, with >99% code coverage, are done in the Magnum 38 | project itself, because there's much better tooling for that. Have a look: 39 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/FunctionTest.cpp 40 | */ 41 | 42 | int main() { 43 | return Containers::Function{[](int a){ return a - 3; }}(3); 44 | } 45 | -------------------------------------------------------------------------------- /test/CorradeGrowableArray.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Corrade. 3 | 4 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 5 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 6 | Vladimír Vondruš 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #include "../CorradeGrowableArray.h" 28 | /* Including second time to verify some symbols don't get accidentally defined 29 | twice due to missing include guards. Mainly important for files that have an 30 | implementation part, but doesn't hurt to test for all. */ 31 | #include "../CorradeGrowableArray.h" 32 | 33 | using namespace Corrade; 34 | 35 | /* 36 | Does this look funny? That's DEFINITELY NOT how testing should look, right? 37 | True dat. The actual tests, with >99% code coverage, are done in the Magnum 38 | project itself, because there's much better tooling for that. Have a look: 39 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/GrowableArrayTest.cpp 40 | */ 41 | 42 | int main() { 43 | Containers::Array a; 44 | arrayAppend(a, 0); 45 | return a.back(); 46 | } 47 | -------------------------------------------------------------------------------- /test/CorradeOptional.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Corrade. 3 | 4 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 5 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 6 | Vladimír Vondruš 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #include "../CorradeOptional.h" 28 | /* Including second time to verify some symbols don't get accidentally defined 29 | twice due to missing include guards. Mainly important for files that have an 30 | implementation part, but doesn't hurt to test for all. */ 31 | #include "../CorradeOptional.h" 32 | 33 | using namespace Corrade; 34 | 35 | /* 36 | Does this look funny? That's DEFINITELY NOT how testing should look, right? 37 | True dat. The actual tests, with >99% code coverage, are done in the Magnum 38 | project itself, because there's much better tooling for that. Have a look: 39 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/OptionalTest.cpp 40 | */ 41 | 42 | int main() { 43 | Containers::Optional a{InPlaceInit, 42}; 44 | return *a - 42; 45 | } 46 | -------------------------------------------------------------------------------- /test/CorradePair.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Corrade. 3 | 4 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 5 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 6 | Vladimír Vondruš 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #include "../CorradePair.h" 28 | /* Including second time to verify some symbols don't get accidentally defined 29 | twice due to missing include guards. Mainly important for files that have an 30 | implementation part, but doesn't hurt to test for all. */ 31 | #include "../CorradePair.h" 32 | 33 | using namespace Corrade; 34 | 35 | /* 36 | Does this look funny? That's DEFINITELY NOT how testing should look, right? 37 | True dat. The actual tests, with >99% code coverage, are done in the Magnum 38 | project itself, because there's much better tooling for that. Have a look: 39 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/PairTest.cpp 40 | */ 41 | 42 | int main() { 43 | #ifndef CORRADE_PAIR_STL_COMPATIBILITY 44 | Containers::Pair a{32, -32}; 45 | #else 46 | Containers::Pair a = std::make_pair(32, -32); 47 | #endif 48 | return a.first() + a.second(); 49 | } 50 | -------------------------------------------------------------------------------- /test/CorradePointer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Corrade. 3 | 4 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 5 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 6 | Vladimír Vondruš 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #include "../CorradePointer.h" 28 | /* Including second time to verify some symbols don't get accidentally defined 29 | twice due to missing include guards. Mainly important for files that have an 30 | implementation part, but doesn't hurt to test for all. */ 31 | #include "../CorradePointer.h" 32 | 33 | using namespace Corrade; 34 | 35 | /* 36 | Does this look funny? That's DEFINITELY NOT how testing should look, right? 37 | True dat. The actual tests, with >99% code coverage, are done in the Magnum 38 | project itself, because there's much better tooling for that. Have a look: 39 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/PointerTest.cpp 40 | */ 41 | 42 | int main() { 43 | #ifndef CORRADE_POINTER_STL_COMPATIBILITY 44 | Containers::Pointer a{InPlaceInit, 42}; 45 | #else 46 | Containers::Pointer a = std::unique_ptr{new int{42}}; 47 | #endif 48 | return *a - 42; 49 | } 50 | -------------------------------------------------------------------------------- /test/CorradeReference.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Corrade. 3 | 4 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 5 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 6 | Vladimír Vondruš 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #include "../CorradeReference.h" 28 | /* Including second time to verify some symbols don't get accidentally defined 29 | twice due to missing include guards. Mainly important for files that have an 30 | implementation part, but doesn't hurt to test for all. */ 31 | #include "../CorradeReference.h" 32 | 33 | using namespace Corrade; 34 | 35 | /* 36 | Does this look funny? That's DEFINITELY NOT how testing should look, right? 37 | True dat. The actual tests, with >99% code coverage, are done in the Magnum 38 | project itself, because there's much better tooling for that. Have a look: 39 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/ReferenceTest.cpp 40 | */ 41 | 42 | int main() { 43 | int a = 42; 44 | #ifndef CORRADE_REFERENCE_STL_COMPATIBILITY 45 | Containers::Reference b{a}; 46 | #else 47 | Containers::Reference b = std::reference_wrapper{a}; 48 | #endif 49 | return *b - 42; 50 | } 51 | -------------------------------------------------------------------------------- /test/CorradeScopeGuard.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Corrade. 3 | 4 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 5 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 6 | Vladimír Vondruš 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #include "../CorradeScopeGuard.h" 28 | /* Including second time to verify some symbols don't get accidentally defined 29 | twice due to missing include guards. Mainly important for files that have an 30 | implementation part, but doesn't hurt to test for all. */ 31 | #include "../CorradeScopeGuard.h" 32 | 33 | using namespace Corrade; 34 | 35 | /* 36 | Does this look funny? That's DEFINITELY NOT how testing should look, right? 37 | True dat. The actual tests, with >99% code coverage, are done in the Magnum 38 | project itself, because there's much better tooling for that. Have a look: 39 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/ScopeGuardTest.cpp 40 | */ 41 | 42 | int main() { 43 | int a = 0; 44 | { 45 | Containers::ScopeGuard guard{&a, [](int* a) { 46 | *a = 42; 47 | }}; 48 | } 49 | return a - 42; 50 | } 51 | -------------------------------------------------------------------------------- /test/CorradeStlForwardArray.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Corrade. 3 | 4 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 5 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 6 | Vladimír Vondruš 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #include "../CorradeStlForwardArray.h" 28 | /* Including second time to verify some symbols don't get accidentally defined 29 | twice due to missing include guards. Mainly important for files that have an 30 | implementation part, but doesn't hurt to test for all. */ 31 | #include "../CorradeStlForwardArray.h" 32 | 33 | int main() { 34 | /* Just verify that this compiles without error */ 35 | std::array* a = nullptr; 36 | return a != nullptr; 37 | } 38 | -------------------------------------------------------------------------------- /test/CorradeStlForwardString.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Corrade. 3 | 4 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 5 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 6 | Vladimír Vondruš 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #include "../CorradeStlForwardString.h" 28 | /* Including second time to verify some symbols don't get accidentally defined 29 | twice due to missing include guards. Mainly important for files that have an 30 | implementation part, but doesn't hurt to test for all. */ 31 | #include "../CorradeStlForwardString.h" 32 | 33 | int main() { 34 | /* Just verify that this compiles without error */ 35 | std::string* a = nullptr; 36 | return a != nullptr; 37 | } 38 | -------------------------------------------------------------------------------- /test/CorradeStlForwardTuple.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Corrade. 3 | 4 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 5 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 6 | Vladimír Vondruš 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #include "../CorradeStlForwardTuple.h" 28 | /* Including second time to verify some symbols don't get accidentally defined 29 | twice due to missing include guards. Mainly important for files that have an 30 | implementation part, but doesn't hurt to test for all. */ 31 | #include "../CorradeStlForwardTuple.h" 32 | 33 | int main() { 34 | /* Just verify that this compiles without error */ 35 | std::tuple* a = nullptr; 36 | return a != nullptr; 37 | } 38 | -------------------------------------------------------------------------------- /test/CorradeStlForwardVector.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Corrade. 3 | 4 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 5 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 6 | Vladimír Vondruš 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #include "../CorradeStlForwardVector.h" 28 | /* Including second time to verify some symbols don't get accidentally defined 29 | twice due to missing include guards. Mainly important for files that have an 30 | implementation part, but doesn't hurt to test for all. */ 31 | #include "../CorradeStlForwardVector.h" 32 | 33 | int main() { 34 | /* Just verify that this compiles without error */ 35 | std::vector* a = nullptr; 36 | return a != nullptr; 37 | } 38 | -------------------------------------------------------------------------------- /test/CorradeStlMath.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Corrade. 3 | 4 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 5 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 6 | Vladimír Vondruš 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #include "../CorradeStlMath.h" 28 | /* Including second time to verify some symbols don't get accidentally defined 29 | twice due to missing include guards. Mainly important for files that have an 30 | implementation part, but doesn't hurt to test for all. */ 31 | #include "../CorradeStlMath.h" 32 | 33 | int main() { 34 | /* std::sin() and such should still be available */ 35 | return int(std::sin(3.141592653589793)); 36 | } 37 | -------------------------------------------------------------------------------- /test/CorradeStridedArrayView.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Corrade. 3 | 4 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 5 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 6 | Vladimír Vondruš 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #include "../CorradeStridedArrayView.h" 28 | /* Including second time to verify some symbols don't get accidentally defined 29 | twice due to missing include guards. Mainly important for files that have an 30 | implementation part, but doesn't hurt to test for all. */ 31 | #include "../CorradeStridedArrayView.h" 32 | 33 | using namespace Corrade; 34 | 35 | /* 36 | Does this look funny? That's DEFINITELY NOT how testing should look, right? 37 | True dat. The actual tests, with >99% code coverage, are done in the Magnum 38 | project itself, because there's much better tooling for that. Have a look: 39 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/StridedArrayViewTest.cpp 40 | */ 41 | 42 | int main() { 43 | int data[]{7}; 44 | 45 | auto a = Containers::stridedArrayView(data); 46 | int i = 0; 47 | for(int j: a.broadcasted<0>(6)) i += j; 48 | return i - 42; 49 | } 50 | -------------------------------------------------------------------------------- /test/CorradeString.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Corrade. 3 | 4 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 5 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 6 | Vladimír Vondruš 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #define CORRADE_CPU_IMPLEMENTATION 28 | #define CORRADE_STRING_IMPLEMENTATION 29 | #include "../CorradeString.hpp" 30 | /* Including second time to verify the implementation (or other) symbols don't 31 | get accidentally defined twice. See comment in the input file for details 32 | how this can happen in practice. */ 33 | #include "../CorradeString.hpp" 34 | 35 | using namespace Corrade; 36 | using namespace Corrade::Containers::Literals; 37 | 38 | /* 39 | Does this look funny? That's DEFINITELY NOT how testing should look, right? 40 | True dat. The actual tests, with >99% code coverage, are done in the Magnum 41 | project itself, because there's much better tooling for that. Have a look: 42 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/StringTest.cpp 43 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/StringStlTest.cpp 44 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/StringStlViewTest.cpp 45 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/StringViewTest.cpp 46 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/StringViewBenchmark.cpp 47 | */ 48 | 49 | int main() { 50 | /* The character lookup delegates to an AVX/SSE, NEON or WASM variant. This 51 | also tests the code from both CORRADE_CPU_IMPLEMENTATION and 52 | CORRADE_STRING_IMPLEMENTATION. */ 53 | return Containers::String{"hello"_s}.contains('l') ? 0 : 1; 54 | } 55 | -------------------------------------------------------------------------------- /test/CorradeTriple.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Corrade. 3 | 4 | Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 5 | 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 6 | Vladimír Vondruš 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #include "../CorradeTriple.h" 28 | /* Including second time to verify some symbols don't get accidentally defined 29 | twice due to missing include guards. Mainly important for files that have an 30 | implementation part, but doesn't hurt to test for all. */ 31 | #include "../CorradeTriple.h" 32 | 33 | using namespace Corrade; 34 | 35 | /* 36 | Does this look funny? That's DEFINITELY NOT how testing should look, right? 37 | True dat. The actual tests, with >99% code coverage, are done in the Magnum 38 | project itself, because there's much better tooling for that. Have a look: 39 | https://github.com/mosra/corrade/blob/master/src/Corrade/Containers/Test/TripleTest.cpp 40 | */ 41 | 42 | int main() { 43 | #ifndef CORRADE_TRIPLE_STL_COMPATIBILITY 44 | Containers::Triple a{32, -4, 8}; 45 | #else 46 | Containers::Triple a = std::make_tuple(32, -4, 8); 47 | #endif 48 | return a.first() + a.second()*a.third(); 49 | } 50 | -------------------------------------------------------------------------------- /test/MagnumMath.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Magnum. 3 | 4 | Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 5 | 2020, 2021, 2022, 2023, 2024, 2025 6 | Vladimír Vondruš 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #define MAGNUM_MATH_IMPLEMENTATION 28 | #include "../MagnumMath.hpp" 29 | /* Including second time to verify the implementation (or other) symbols don't 30 | get accidentally defined twice. See comment in the input file for details 31 | how this can happen in practice. */ 32 | #include "../MagnumMath.hpp" 33 | 34 | using namespace Magnum; 35 | 36 | /* 37 | Does this look funny? That's DEFINITELY NOT how testing should look, right? 38 | True dat. The actual tests, with >99% code coverage, are done in the Magnum 39 | project itself, because there's much better tooling for that. Have a look: 40 | https://github.com/mosra/magnum/tree/master/src/Magnum/Math/Test 41 | */ 42 | 43 | int main() { 44 | Vector4i a{3, 42, 57, -1}; 45 | 46 | /* The log2() call tests code from MAGNUM_MATH_IMPLEMENTATION */ 47 | return a[1] - 40 - Math::log2(4); 48 | } 49 | -------------------------------------------------------------------------------- /test/MagnumMathBatch.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Magnum. 3 | 4 | Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 5 | 2020, 2021, 2022, 2023, 2024, 2025 6 | Vladimír Vondruš 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #define MAGNUM_MATH_BATCH_IMPLEMENTATION 28 | #include "../MagnumMathBatch.hpp" 29 | /* Including second time to verify the implementation (or other) symbols don't 30 | get accidentally defined twice. See comment in the input file for details 31 | how this can happen in practice. */ 32 | #include "../MagnumMathBatch.hpp" 33 | 34 | using namespace Magnum; 35 | 36 | /* 37 | Does this look funny? That's DEFINITELY NOT how testing should look, right? 38 | True dat. The actual tests, with >99% code coverage, are done in the Magnum 39 | project itself, because there's much better tooling for that. Have a look: 40 | https://github.com/mosra/magnum/tree/master/src/Magnum/Math/Test 41 | */ 42 | 43 | int main() { 44 | const Long in[]{3, 5, -17, 32}; 45 | Short out[4]; 46 | /* The castInto() tests code from MAGNUM_MATH_BATCH_IMPLEMENTATION */ 47 | Math::castInto(Containers::stridedArrayView(in), 48 | Containers::stridedArrayView(out)); 49 | 50 | return Math::max(Containers::stridedArrayView(out)) - 32; 51 | } 52 | -------------------------------------------------------------------------------- /test/MagnumMeshTools.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Magnum. 3 | 4 | Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 5 | 2020, 2021, 2022, 2023, 2024, 2025 6 | Vladimír Vondruš 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the "Software"), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #define MAGNUM_MESHTOOLS_IMPLEMENTATION 28 | #include "../MagnumMeshTools.hpp" 29 | /* Including second time to verify the implementation (or other) symbols don't 30 | get accidentally defined twice. See comment in the input file for details 31 | how this can happen in practice. */ 32 | #include "../MagnumMeshTools.hpp" 33 | 34 | using namespace Magnum; 35 | 36 | /* 37 | Does this look funny? That's DEFINITELY NOT how testing should look, right? 38 | True dat. The actual tests, with >99% code coverage, are done in the Magnum 39 | project itself, because there's much better tooling for that. Have a look: 40 | https://github.com/mosra/magnum/tree/master/src/Magnum/Math/Test 41 | */ 42 | 43 | int main() { 44 | /* This tests code from MAGNUM_MESHTOOLS_IMPLEMENTATION */ 45 | return MeshTools::generateTriangleFanIndices(10)[6]; 46 | } 47 | --------------------------------------------------------------------------------