diff --git a/LICENSE-3RD-PARTY b/LICENSE-3RD-PARTY
index 9827f1df..b79e16bd 100644
--- a/LICENSE-3RD-PARTY
+++ b/LICENSE-3RD-PARTY
@@ -12,7 +12,6 @@ This software is based on the following MIT licensed projects:
- Plog : Copyright (c) 2022 Sergey Podobry
- pugixml : Copyright (c) 2006-2023 Arseny Kapoulkine
- ValveFileVDF : Copyright (c) Matthias Moeller 2016 m_moeller@live.de
-- Guidelines Support Library (GSL) : Copyright (c) 2015 Microsoft Corporation. All rights reserved.
- HybridDetect : Copyright (c) 2017 Intel
---
diff --git a/README.md b/README.md
index 62a6150b..b4985173 100644
--- a/README.md
+++ b/README.md
@@ -75,7 +75,6 @@ SKIF supports detecting and launching games from the following platforms:
* Uses [Plog](https://github.com/SergiusTheBest/plog), licensed under [MIT](https://github.com/SergiusTheBest/plog/blob/master/LICENSE).
* Uses [pugixml](https://pugixml.org/), licensed under [MIT](https://pugixml.org/license.html).
* Uses [ValveFileVDF](https://github.com/TinyTinni/ValveFileVDF), licensed under [MIT](https://github.com/TinyTinni/ValveFileVDF/blob/master/LICENSE).
-* Uses [Guidelines Support Library (GSL)](https://github.com/microsoft/GSL), licensed under [MIT](https://github.com/microsoft/GSL/blob/main/LICENSE).
* Uses [TextFlowCpp](https://github.com/catchorg/textflowcpp), licensed under [BSL-1.0](https://github.com/catchorg/textflowcpp/blob/master/LICENSE.txt).
* Uses [HybridDetect](https://github.com/GameTechDev/HybridDetect/), licensed under [MIT](https://github.com/GameTechDev/HybridDetect/blob/main/LICENSE.md).
* Uses code from [Custom Resolution Utility (CRU)](https://www.monitortests.com/forum/Thread-Custom-Resolution-Utility-CRU), licensed under a [custom license](https://github.com/SpecialKO/SKIF/blob/master/src/utility/drvreset.cpp).
diff --git a/SKIF.vcxproj b/SKIF.vcxproj
index 83e01b37..71ab035f 100644
--- a/SKIF.vcxproj
+++ b/SKIF.vcxproj
@@ -544,15 +544,6 @@
-
-
-
-
-
-
-
-
-
diff --git a/SKIF.vcxproj.filters b/SKIF.vcxproj.filters
index 2c71ec91..a22f0736 100644
--- a/SKIF.vcxproj.filters
+++ b/SKIF.vcxproj.filters
@@ -82,9 +82,6 @@
{9fb4cf13-f304-4e2c-a64a-0fb28fa175f2}
-
- {995078a9-45f5-4bd8-8760-dec8aed20f6d}
-
@@ -379,32 +376,5 @@
-
- Header Files\Packages_Misc\GSL
-
-
- Header Files\Packages_Misc\GSL
-
-
- Header Files\Packages_Misc\GSL
-
-
- Header Files\Packages_Misc\GSL
-
-
- Header Files\Packages_Misc\GSL
-
-
- Header Files\Packages_Misc\GSL
-
-
- Header Files\Packages_Misc\GSL
-
-
- Header Files\Packages_Misc\GSL
-
-
- Header Files\Packages_Misc\GSL
-
\ No newline at end of file
diff --git a/packages_misc/gsl/gsl b/packages_misc/gsl/gsl
deleted file mode 100644
index 55862ebd..00000000
--- a/packages_misc/gsl/gsl
+++ /dev/null
@@ -1,29 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-// Copyright (c) 2015 Microsoft Corporation. All rights reserved.
-//
-// This code is licensed under the MIT License (MIT).
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef GSL_GSL_H
-#define GSL_GSL_H
-
-#include // copy
-#include // Ensures/Expects
-#include // byte
-#include // finally()/narrow()/narrow_cast()...
-#include // multi_span, strided_span...
-#include // owner, not_null
-#include // span
-#include // zstring, string_span, zstring_builder...
-
-#endif // GSL_GSL_H
diff --git a/packages_misc/gsl/gsl_algorithm b/packages_misc/gsl/gsl_algorithm
deleted file mode 100644
index c2ba31f3..00000000
--- a/packages_misc/gsl/gsl_algorithm
+++ /dev/null
@@ -1,61 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-// Copyright (c) 2015 Microsoft Corporation. All rights reserved.
-//
-// This code is licensed under the MIT License (MIT).
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef GSL_ALGORITHM_H
-#define GSL_ALGORITHM_H
-
-#include // for Expects
-#include // for dynamic_extent, span
-
-#include // for copy_n
-#include // for ptrdiff_t
-#include // for is_assignable
-
-#ifdef _MSC_VER
-#pragma warning(push)
-
-// turn off some warnings that are noisy about our Expects statements
-#pragma warning(disable : 4127) // conditional expression is constant
-#pragma warning(disable : 4996) // unsafe use of std::copy_n
-
-#endif // _MSC_VER
-
-namespace gsl
-{
-// Note: this will generate faster code than std::copy using span iterator in older msvc+stl
-// not necessary for msvc since VS2017 15.8 (_MSC_VER >= 1915)
-template
-void copy(span src, span dest)
-{
- static_assert(std::is_assignable::value,
- "Elements of source span can not be assigned to elements of destination span");
- static_assert(SrcExtent == dynamic_extent || DestExtent == dynamic_extent ||
- (SrcExtent <= DestExtent),
- "Source range is longer than target range");
-
- Expects(dest.size() >= src.size());
- GSL_SUPPRESS(stl.1) // NO-FORMAT: attribute
- std::copy_n(src.data(), src.size(), dest.data());
-}
-
-} // namespace gsl
-
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif // _MSC_VER
-
-#endif // GSL_ALGORITHM_H
diff --git a/packages_misc/gsl/gsl_assert b/packages_misc/gsl/gsl_assert
deleted file mode 100644
index c7046339..00000000
--- a/packages_misc/gsl/gsl_assert
+++ /dev/null
@@ -1,177 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-// Copyright (c) 2015 Microsoft Corporation. All rights reserved.
-//
-// This code is licensed under the MIT License (MIT).
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef GSL_CONTRACTS_H
-#define GSL_CONTRACTS_H
-
-#include
-#include // for logic_error
-
-//
-// make suppress attributes parse for some compilers
-// Hopefully temporary until suppression standardization occurs
-//
-#if defined(__clang__)
-#define GSL_SUPPRESS(x) [[gsl::suppress("x")]]
-#else
-#if defined(_MSC_VER)
-#define GSL_SUPPRESS(x) [[gsl::suppress(x)]]
-#else
-#define GSL_SUPPRESS(x)
-#endif // _MSC_VER
-#endif // __clang__
-
-//
-// Temporary until MSVC STL supports no-exceptions mode.
-// Currently terminate is a no-op in this mode, so we add termination behavior back
-//
-#if defined(_MSC_VER) && defined(_HAS_EXCEPTIONS) && !_HAS_EXCEPTIONS
-#define GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND
-#include
-#define RANGE_CHECKS_FAILURE 0
-
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Winvalid-noreturn"
-#endif
-
-#endif
-
-//
-// There are three configuration options for this GSL implementation's behavior
-// when pre/post conditions on the GSL types are violated:
-//
-// 1. GSL_TERMINATE_ON_CONTRACT_VIOLATION: std::terminate will be called (default)
-// 2. GSL_THROW_ON_CONTRACT_VIOLATION: a gsl::fail_fast exception will be thrown
-// 3. GSL_UNENFORCED_ON_CONTRACT_VIOLATION: nothing happens
-//
-#if !(defined(GSL_THROW_ON_CONTRACT_VIOLATION) || defined(GSL_TERMINATE_ON_CONTRACT_VIOLATION) || \
- defined(GSL_UNENFORCED_ON_CONTRACT_VIOLATION))
-#define GSL_TERMINATE_ON_CONTRACT_VIOLATION
-#endif
-
-#define GSL_STRINGIFY_DETAIL(x) #x
-#define GSL_STRINGIFY(x) GSL_STRINGIFY_DETAIL(x)
-
-#if defined(__clang__) || defined(__GNUC__)
-#define GSL_LIKELY(x) __builtin_expect(!!(x), 1)
-#define GSL_UNLIKELY(x) __builtin_expect(!!(x), 0)
-#else
-#define GSL_LIKELY(x) (!!(x))
-#define GSL_UNLIKELY(x) (!!(x))
-#endif
-
-//
-// GSL_ASSUME(cond)
-//
-// Tell the optimizer that the predicate cond must hold. It is unspecified
-// whether or not cond is actually evaluated.
-//
-#ifdef _MSC_VER
-#define GSL_ASSUME(cond) __assume(cond)
-#elif defined(__GNUC__)
-#define GSL_ASSUME(cond) ((cond) ? static_cast(0) : __builtin_unreachable())
-#else
-#define GSL_ASSUME(cond) static_cast((cond) ? 0 : 0)
-#endif
-
-//
-// GSL.assert: assertions
-//
-
-namespace gsl
-{
-struct fail_fast : public std::logic_error
-{
- explicit fail_fast(char const* const message) : std::logic_error(message) {}
-};
-
-namespace details
-{
-#if defined(GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND)
-
- typedef void (__cdecl *terminate_handler)();
-
- GSL_SUPPRESS(f.6) // NO-FORMAT: attribute
- [[noreturn]] inline void __cdecl default_terminate_handler()
- {
- __fastfail(RANGE_CHECKS_FAILURE);
- }
-
- inline gsl::details::terminate_handler& get_terminate_handler() noexcept
- {
- static terminate_handler handler = &default_terminate_handler;
- return handler;
- }
-
-#endif
-
- [[noreturn]] inline void terminate() noexcept
- {
-#if defined(GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND)
- (*gsl::details::get_terminate_handler())();
-#else
- std::terminate();
-#endif
- }
-
-#if defined(GSL_TERMINATE_ON_CONTRACT_VIOLATION)
-
- template
- [[noreturn]] void throw_exception(Exception&&) noexcept
- {
- gsl::details::terminate();
- }
-
-#else
-
- template
- [[noreturn]] void throw_exception(Exception&& exception)
- {
- throw std::forward(exception);
- }
-
-#endif // GSL_TERMINATE_ON_CONTRACT_VIOLATION
-
-} // namespace details
-} // namespace gsl
-
-#if defined(GSL_THROW_ON_CONTRACT_VIOLATION)
-
-#define GSL_CONTRACT_CHECK(type, cond) \
- (GSL_LIKELY(cond) ? static_cast(0) \
- : gsl::details::throw_exception(gsl::fail_fast( \
- "GSL: " type " failure at " __FILE__ ": " GSL_STRINGIFY(__LINE__))))
-
-#elif defined(GSL_TERMINATE_ON_CONTRACT_VIOLATION)
-
-#define GSL_CONTRACT_CHECK(type, cond) \
- (GSL_LIKELY(cond) ? static_cast(0) : gsl::details::terminate())
-
-#elif defined(GSL_UNENFORCED_ON_CONTRACT_VIOLATION)
-
-#define GSL_CONTRACT_CHECK(type, cond) GSL_ASSUME(cond)
-
-#endif // GSL_THROW_ON_CONTRACT_VIOLATION
-
-#define Expects(cond) GSL_CONTRACT_CHECK("Precondition", cond)
-#define Ensures(cond) GSL_CONTRACT_CHECK("Postcondition", cond)
-
-#if defined(GSL_MSVC_USE_STL_NOEXCEPTION_WORKAROUND) && defined(__clang__)
-#pragma clang diagnostic pop
-#endif
-
-#endif // GSL_CONTRACTS_H
diff --git a/packages_misc/gsl/gsl_byte b/packages_misc/gsl/gsl_byte
deleted file mode 100644
index 861446dc..00000000
--- a/packages_misc/gsl/gsl_byte
+++ /dev/null
@@ -1,203 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-// Copyright (c) 2015 Microsoft Corporation. All rights reserved.
-//
-// This code is licensed under the MIT License (MIT).
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef GSL_BYTE_H
-#define GSL_BYTE_H
-
-//
-// make suppress attributes work for some compilers
-// Hopefully temporary until suppression standardization occurs
-//
-#if defined(__clang__)
-#define GSL_SUPPRESS(x) [[gsl::suppress("x")]]
-#else
-#if defined(_MSC_VER)
-#define GSL_SUPPRESS(x) [[gsl::suppress(x)]]
-#else
-#define GSL_SUPPRESS(x)
-#endif // _MSC_VER
-#endif // __clang__
-
-#include
-
-#ifdef _MSC_VER
-
-#pragma warning(push)
-
-// Turn MSVC /analyze rules that generate too much noise. TODO: fix in the tool.
-#pragma warning(disable : 26493) // don't use c-style casts // TODO: MSVC suppression in templates does not always work
-
-#ifndef GSL_USE_STD_BYTE
-// this tests if we are under MSVC and the standard lib has std::byte and it is enabled
-#if defined(_HAS_STD_BYTE) && _HAS_STD_BYTE
-
-#define GSL_USE_STD_BYTE 1
-
-#else // defined(_HAS_STD_BYTE) && _HAS_STD_BYTE
-
-#define GSL_USE_STD_BYTE 0
-
-#endif // defined(_HAS_STD_BYTE) && _HAS_STD_BYTE
-#endif // GSL_USE_STD_BYTE
-
-#else // _MSC_VER
-
-#ifndef GSL_USE_STD_BYTE
-// this tests if we are under GCC or Clang with enough -std:c++1z power to get us std::byte
-// also check if libc++ version is sufficient (> 5.0) or libstc++ actually contains std::byte
-#if defined(__cplusplus) && (__cplusplus >= 201703L) && \
- (defined(__cpp_lib_byte) && (__cpp_lib_byte >= 201603) || \
- defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION >= 5000))
-
-#define GSL_USE_STD_BYTE 1
-#include
-
-#else // defined(__cplusplus) && (__cplusplus >= 201703L) &&
- // (defined(__cpp_lib_byte) && (__cpp_lib_byte >= 201603) ||
- // defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION >= 5000))
-
-#define GSL_USE_STD_BYTE 0
-
-#endif //defined(__cplusplus) && (__cplusplus >= 201703L) &&
- // (defined(__cpp_lib_byte) && (__cpp_lib_byte >= 201603) ||
- // defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION >= 5000))
-#endif // GSL_USE_STD_BYTE
-
-#endif // _MSC_VER
-
-// Use __may_alias__ attribute on gcc and clang
-#if defined __clang__ || (defined(__GNUC__) && __GNUC__ > 5)
-#define byte_may_alias __attribute__((__may_alias__))
-#else // defined __clang__ || defined __GNUC__
-#define byte_may_alias
-#endif // defined __clang__ || defined __GNUC__
-
-namespace gsl
-{
-#if GSL_USE_STD_BYTE
-
-using std::byte;
-using std::to_integer;
-
-#else // GSL_USE_STD_BYTE
-
-// This is a simple definition for now that allows
-// use of byte within span<> to be standards-compliant
-enum class byte_may_alias byte : unsigned char
-{
-};
-
-template ::value>>
-constexpr byte& operator<<=(byte& b, IntegerType shift) noexcept
-{
- return b = byte(static_cast(b) << shift);
-}
-
-template ::value>>
-constexpr byte operator<<(byte b, IntegerType shift) noexcept
-{
- return byte(static_cast(b) << shift);
-}
-
-template ::value>>
-constexpr byte& operator>>=(byte& b, IntegerType shift) noexcept
-{
- return b = byte(static_cast(b) >> shift);
-}
-
-template ::value>>
-constexpr byte operator>>(byte b, IntegerType shift) noexcept
-{
- return byte(static_cast(b) >> shift);
-}
-
-constexpr byte& operator|=(byte& l, byte r) noexcept
-{
- return l = byte(static_cast(l) | static_cast(r));
-}
-
-constexpr byte operator|(byte l, byte r) noexcept
-{
- return byte(static_cast(l) | static_cast(r));
-}
-
-constexpr byte& operator&=(byte& l, byte r) noexcept
-{
- return l = byte(static_cast(l) & static_cast(r));
-}
-
-constexpr byte operator&(byte l, byte r) noexcept
-{
- return byte(static_cast(l) & static_cast(r));
-}
-
-constexpr byte& operator^=(byte& l, byte r) noexcept
-{
- return l = byte(static_cast(l) ^ static_cast(r));
-}
-
-constexpr byte operator^(byte l, byte r) noexcept
-{
- return byte(static_cast(l) ^ static_cast(r));
-}
-
-constexpr byte operator~(byte b) noexcept { return byte(~static_cast(b)); }
-
-template ::value>>
-constexpr IntegerType to_integer(byte b) noexcept
-{
- return static_cast(b);
-}
-
-#endif // GSL_USE_STD_BYTE
-
-template
-constexpr byte to_byte_impl(T t) noexcept
-{
- static_assert(
- E, "gsl::to_byte(t) must be provided an unsigned char, otherwise data loss may occur. "
- "If you are calling to_byte with an integer contant use: gsl::to_byte() version.");
- return static_cast(t);
-}
-template <>
-// NOTE: need suppression since c++14 does not allow "return {t}"
-// GSL_SUPPRESS(type.4) // NO-FORMAT: attribute // TODO: suppression does not work
-constexpr byte to_byte_impl(unsigned char t) noexcept
-{
- return byte(t);
-}
-
-template
-constexpr byte to_byte(T t) noexcept
-{
- return to_byte_impl::value, T>(t);
-}
-
-template
-constexpr byte to_byte() noexcept
-{
- static_assert(I >= 0 && I <= 255,
- "gsl::byte only has 8 bits of storage, values must be in range 0-255");
- return static_cast(I);
-}
-
-} // namespace gsl
-
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif // _MSC_VER
-
-#endif // GSL_BYTE_H
diff --git a/packages_misc/gsl/gsl_util b/packages_misc/gsl/gsl_util
deleted file mode 100644
index e4c7dda4..00000000
--- a/packages_misc/gsl/gsl_util
+++ /dev/null
@@ -1,176 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-// Copyright (c) 2015 Microsoft Corporation. All rights reserved.
-//
-// This code is licensed under the MIT License (MIT).
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef GSL_UTIL_H
-#define GSL_UTIL_H
-
-#include // for Expects
-
-#include
-#include // for ptrdiff_t, size_t
-#include // for exception
-#include // for initializer_list
-#include // for is_signed, integral_constant
-#include // for forward
-
-#if defined(_MSC_VER) && !defined(__clang__)
-
-#pragma warning(push)
-#pragma warning(disable : 4127) // conditional expression is constant
-
-#if _MSC_VER < 1910
-#pragma push_macro("constexpr")
-#define constexpr /*constexpr*/
-#endif // _MSC_VER < 1910
-#endif // _MSC_VER
-
-#if (defined(_MSC_VER) && _MSC_VER < 1910) || (!defined(__clang__) && defined(__GNUC__) && __GUNC__ < 6)
-#define GSL_CONSTEXPR_NARROW 0
-#else
-#define GSL_CONSTEXPR_NARROW 1
-#endif
-
-namespace gsl
-{
-//
-// GSL.util: utilities
-//
-
-// index type for all container indexes/subscripts/sizes
-using index = std::ptrdiff_t;
-
-// final_action allows you to ensure something gets run at the end of a scope
-template
-class final_action
-{
-public:
- explicit final_action(F f) noexcept : f_(std::move(f)) {}
-
- final_action(final_action&& other) noexcept : f_(std::move(other.f_)), invoke_(other.invoke_)
- {
- other.invoke_ = false;
- }
-
- final_action(const final_action&) = delete;
- final_action& operator=(const final_action&) = delete;
- final_action& operator=(final_action&&) = delete;
-
- GSL_SUPPRESS(f.6) // NO-FORMAT: attribute // terminate if throws
- ~final_action() noexcept
- {
- if (invoke_) f_();
- }
-
-private:
- F f_;
- bool invoke_{true};
-};
-
-// finally() - convenience function to generate a final_action
-template
-final_action finally(const F& f) noexcept
-{
- return final_action(f);
-}
-
-template
-final_action finally(F&& f) noexcept
-{
- return final_action(std::forward(f));
-}
-
-// narrow_cast(): a searchable way to do narrowing casts of values
-template
-GSL_SUPPRESS(type.1) // NO-FORMAT: attribute
-constexpr T narrow_cast(U&& u) noexcept
-{
- return static_cast(std::forward(u));
-}
-
-struct narrowing_error : public std::exception
-{
-};
-
-namespace details
-{
- template
- struct is_same_signedness
- : public std::integral_constant::value == std::is_signed::value>
- {
- };
-} // namespace details
-
-// narrow() : a checked version of narrow_cast() that throws if the cast changed the value
-template
-GSL_SUPPRESS(type.1) // NO-FORMAT: attribute
-GSL_SUPPRESS(f.6) // NO-FORMAT: attribute // TODO: MSVC /analyze does not recognise noexcept(false)
-#if GSL_CONSTEXPR_NARROW
-constexpr
-#endif
-T narrow(U u) noexcept(false)
-{
- T t = narrow_cast(u);
- if (static_cast(t) != u) gsl::details::throw_exception(narrowing_error());
- if (!details::is_same_signedness::value && ((t < T{}) != (u < U{})))
- gsl::details::throw_exception(narrowing_error());
- return t;
-}
-
-//
-// at() - Bounds-checked way of accessing builtin arrays, std::array, std::vector
-//
-template
-GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
-GSL_SUPPRESS(bounds.2) // NO-FORMAT: attribute
-constexpr T& at(T (&arr)[N], const index i)
-{
- Expects(i >= 0 && i < narrow_cast(N));
- return arr[narrow_cast(i)];
-}
-
-template
-GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
-GSL_SUPPRESS(bounds.2) // NO-FORMAT: attribute
-constexpr auto at(Cont& cont, const index i) -> decltype(cont[cont.size()])
-{
- Expects(i >= 0 && i < narrow_cast(cont.size()));
- using size_type = decltype(cont.size());
- return cont[narrow_cast(i)];
-}
-
-template
-GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
-constexpr T at(const std::initializer_list cont, const index i)
-{
- Expects(i >= 0 && i < narrow_cast(cont.size()));
- return *(cont.begin() + i);
-}
-
-} // namespace gsl
-
-#if defined(_MSC_VER) && !defined(__clang__)
-#if _MSC_VER < 1910
-#undef constexpr
-#pragma pop_macro("constexpr")
-
-#endif // _MSC_VER < 1910
-
-#pragma warning(pop)
-
-#endif // _MSC_VER
-
-#endif // GSL_UTIL_H
-
diff --git a/packages_misc/gsl/multi_span b/packages_misc/gsl/multi_span
deleted file mode 100644
index f1a909e1..00000000
--- a/packages_misc/gsl/multi_span
+++ /dev/null
@@ -1,2293 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-// Copyright (c) 2015 Microsoft Corporation. All rights reserved.
-//
-// This code is licensed under the MIT License (MIT).
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef GSL_MULTI_SPAN_H
-#define GSL_MULTI_SPAN_H
-
-#include // for Expects
-#include // for byte
-#include // for narrow_cast
-
-#include // for transform, lexicographical_compare
-#include // for array
-#include
-#include // for ptrdiff_t, size_t, nullptr_t
-#include // for PTRDIFF_MAX
-#include // for divides, multiplies, minus, negate, plus
-#include // for initializer_list
-#include // for iterator, random_access_iterator_tag
-#include // for numeric_limits
-#include
-#include
-#include
-#include // for basic_string
-#include // for enable_if_t, remove_cv_t, is_same, is_co...
-#include
-
-#if defined(_MSC_VER) && !defined(__clang__)
-
-// turn off some warnings that are noisy about our Expects statements
-#pragma warning(push)
-#pragma warning(disable : 4127) // conditional expression is constant
-#pragma warning(disable : 4702) // unreachable code
-
-// Turn MSVC /analyze rules that generate too much noise. TODO: fix in the tool.
-#pragma warning(disable : 26495) // uninitalized member when constructor calls constructor
-#pragma warning(disable : 26473) // in some instantiations we cast to the same type
-#pragma warning(disable : 26490) // TODO: bug in parser - attributes and templates
-#pragma warning(disable : 26465) // TODO: bug - suppression does not work on template functions
-
-#if _MSC_VER < 1910
-#pragma push_macro("constexpr")
-#define constexpr /*constexpr*/
-
-#endif // _MSC_VER < 1910
-#endif // _MSC_VER
-
-// GCC 7 does not like the signed unsigned missmatch (size_t ptrdiff_t)
-// While there is a conversion from signed to unsigned, it happens at
-// compiletime, so the compiler wouldn't have to warn indiscriminently, but
-// could check if the source value actually doesn't fit into the target type
-// and only warn in those cases.
-#if defined(__GNUC__) && __GNUC__ > 6
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-conversion"
-#endif
-
-namespace gsl
-{
-
-/*
-** begin definitions of index and bounds
-*/
-namespace details
-{
- template
- struct SizeTypeTraits
- {
- static const SizeType max_value = std::numeric_limits::max();
- };
-
- template
- class are_integral : public std::integral_constant
- {
- };
-
- template
- class are_integral
- : public std::integral_constant::value && are_integral::value>
- {
- };
-} // namespace details
-
-template
-class multi_span_index final
-{
- static_assert(Rank > 0, "Rank must be greater than 0!");
-
- template
- friend class multi_span_index;
-
-public:
- static const std::size_t rank = Rank;
- using value_type = std::ptrdiff_t;
- using size_type = value_type;
- using reference = std::add_lvalue_reference_t;
- using const_reference = std::add_lvalue_reference_t>;
-
- constexpr multi_span_index() noexcept {}
-
- constexpr multi_span_index(const value_type (&values)[Rank]) noexcept
- {
- GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
- GSL_SUPPRESS(bounds.3) // NO-FORMAT: attribute
- std::copy(values, values + Rank, elems);
- }
-
- template ::value>>
- constexpr multi_span_index(Ts... ds) noexcept : elems{narrow_cast(ds)...}
- {}
-
- constexpr multi_span_index(const multi_span_index& other) noexcept = default;
-
- constexpr multi_span_index& operator=(const multi_span_index& rhs) noexcept = default;
-
- // Preconditions: component_idx < rank
- GSL_SUPPRESS(bounds.2) // NO-FORMAT: attribute
- GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
- constexpr reference operator[](std::size_t component_idx)
- {
- Expects(component_idx < Rank); // Component index must be less than rank
- return elems[component_idx];
- }
-
- // Preconditions: component_idx < rank
- GSL_SUPPRESS(bounds.2) // NO-FORMAT: attribute
- GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
- constexpr const_reference operator[](std::size_t component_idx) const
- {
- Expects(component_idx < Rank); // Component index must be less than rank
- return elems[component_idx];
- }
-
- GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
- GSL_SUPPRESS(bounds.3) // NO-FORMAT: attribute
- constexpr bool operator==(const multi_span_index& rhs) const
- {
- return std::equal(elems, elems + rank, rhs.elems);
- }
-
- constexpr bool operator!=(const multi_span_index& rhs) const
- {
- return !(*this == rhs);
- }
-
- constexpr multi_span_index operator+() const noexcept { return *this; }
-
- constexpr multi_span_index operator-() const
- {
- multi_span_index ret = *this;
- std::transform(ret, ret + rank, ret, std::negate{});
- return ret;
- }
-
- constexpr multi_span_index operator+(const multi_span_index& rhs) const
- {
- multi_span_index ret = *this;
- ret += rhs;
- return ret;
- }
-
- constexpr multi_span_index operator-(const multi_span_index& rhs) const
- {
- multi_span_index ret = *this;
- ret -= rhs;
- return ret;
- }
-
- constexpr multi_span_index& operator+=(const multi_span_index& rhs)
- {
- GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
- GSL_SUPPRESS(bounds.3) // NO-FORMAT: attribute
- std::transform(elems, elems + rank, rhs.elems, elems,
- std::plus{});
- return *this;
- }
-
- constexpr multi_span_index& operator-=(const multi_span_index& rhs)
- {
- GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
- GSL_SUPPRESS(bounds.3) // NO-FORMAT: attribute
- std::transform(elems, elems + rank, rhs.elems, elems, std::minus{});
- return *this;
- }
-
- constexpr multi_span_index operator*(value_type v) const
- {
- multi_span_index ret = *this;
- ret *= v;
- return ret;
- }
-
- constexpr multi_span_index operator/(value_type v) const
- {
- multi_span_index ret = *this;
- ret /= v;
- return ret;
- }
-
- friend constexpr multi_span_index operator*(value_type v, const multi_span_index& rhs)
- {
- return rhs * v;
- }
-
- constexpr multi_span_index& operator*=(value_type v)
- {
- GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
- GSL_SUPPRESS(bounds.3) // NO-FORMAT: attribute
- std::transform(elems, elems + rank, elems,
- [v](value_type x) { return std::multiplies{}(x, v); });
- return *this;
- }
-
- constexpr multi_span_index& operator/=(value_type v)
- {
- GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
- GSL_SUPPRESS(bounds.3) // NO-FORMAT: attribute
- std::transform(elems, elems + rank, elems,
- [v](value_type x) { return std::divides{}(x, v); });
- return *this;
- }
-
-private:
- value_type elems[Rank] = {};
-};
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1910
-
-struct static_bounds_dynamic_range_t
-{
- template ::value>>
- constexpr operator T() const noexcept
- {
- return narrow_cast(-1);
- }
-};
-
-constexpr bool operator==(static_bounds_dynamic_range_t, static_bounds_dynamic_range_t) noexcept
-{
- return true;
-}
-
-constexpr bool operator!=(static_bounds_dynamic_range_t, static_bounds_dynamic_range_t) noexcept
-{
- return false;
-}
-
-template ::value>>
-constexpr bool operator==(static_bounds_dynamic_range_t, T other) noexcept
-{
- return narrow_cast(-1) == other;
-}
-
-template ::value>>
-constexpr bool operator==(T left, static_bounds_dynamic_range_t right) noexcept
-{
- return right == left;
-}
-
-template ::value>>
-constexpr bool operator!=(static_bounds_dynamic_range_t, T other) noexcept
-{
- return narrow_cast(-1) != other;
-}
-
-template ::value>>
-constexpr bool operator!=(T left, static_bounds_dynamic_range_t right) noexcept
-{
- return right != left;
-}
-
-constexpr static_bounds_dynamic_range_t dynamic_range{};
-#else
-const std::ptrdiff_t dynamic_range = -1;
-#endif
-
-struct generalized_mapping_tag
-{
-};
-struct contiguous_mapping_tag : generalized_mapping_tag
-{
-};
-
-namespace details
-{
-
- template
- struct LessThan
- {
- static const bool value = Left < Right;
- };
-
- template
- struct BoundsRanges
- {
- using size_type = std::ptrdiff_t;
- static const size_type Depth = 0;
- static const size_type DynamicNum = 0;
- static const size_type CurrentRange = 1;
- static const size_type TotalSize = 1;
-
- // TODO : following signature is for work around VS bug
- template
- constexpr BoundsRanges(const OtherRange&, bool /* firstLevel */)
- {}
-
- constexpr BoundsRanges(const std::ptrdiff_t* const) {}
- constexpr BoundsRanges() noexcept = default;
-
- template
- constexpr void serialize(T&) const
- {}
-
- template
- constexpr size_type linearize(const T&) const
- {
- return 0;
- }
-
- template
- constexpr size_type contains(const T&) const
- {
- return -1;
- }
-
- constexpr size_type elementNum(std::size_t) const noexcept { return 0; }
-
- constexpr size_type totalSize() const noexcept { return TotalSize; }
-
- constexpr bool operator==(const BoundsRanges&) const noexcept { return true; }
- };
-
- template
- struct BoundsRanges : BoundsRanges
- {
- using Base = BoundsRanges;
- using size_type = std::ptrdiff_t;
- static const std::size_t Depth = Base::Depth + 1;
- static const std::size_t DynamicNum = Base::DynamicNum + 1;
- static const size_type CurrentRange = dynamic_range;
- static const size_type TotalSize = dynamic_range;
-
- private:
- size_type m_bound;
-
- public:
- GSL_SUPPRESS(f.23) // NO-FORMAT: attribute // this pointer type is cannot be assigned nullptr - issue in not_null
- GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
- constexpr BoundsRanges(const std::ptrdiff_t* const arr)
- : Base(arr + 1), m_bound(*arr * this->Base::totalSize())
- {
- Expects(0 <= *arr);
- }
-
- constexpr BoundsRanges() noexcept : m_bound(0) {}
-
- template
- constexpr BoundsRanges(const BoundsRanges& other,
- bool /* firstLevel */ = true)
- : Base(static_cast&>(other), false)
- , m_bound(other.totalSize())
- {}
-
- template
- constexpr void serialize(T& arr) const
- {
- arr[Dim] = elementNum();
- this->Base::template serialize(arr);
- }
-
- template
- GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
- constexpr size_type linearize(const T& arr) const
- {
- const size_type index = this->Base::totalSize() * arr[Dim];
- Expects(index < m_bound);
- return index + this->Base::template linearize(arr);
- }
-
- template
- constexpr size_type contains(const T& arr) const
- {
- const ptrdiff_t last = this->Base::template contains(arr);
- if (last == -1) return -1;
- const ptrdiff_t cur = this->Base::totalSize() * arr[Dim];
- return cur < m_bound ? cur + last : -1;
- }
-
- GSL_SUPPRESS(c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used
- constexpr size_type totalSize() const noexcept
- {
- return m_bound;
- }
-
- GSL_SUPPRESS(c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used
- constexpr size_type elementNum() const noexcept
- {
- return totalSize() / this->Base::totalSize();
- }
-
- GSL_SUPPRESS(c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used
- constexpr size_type elementNum(std::size_t dim) const noexcept
- {
- if (dim > 0)
- return this->Base::elementNum(dim - 1);
- else
- return elementNum();
- }
-
- constexpr bool operator==(const BoundsRanges& rhs) const noexcept
- {
- return m_bound == rhs.m_bound &&
- static_cast(*this) == static_cast(rhs);
- }
- };
-
- template
- struct BoundsRanges : BoundsRanges
- {
- using Base = BoundsRanges;
- using size_type = std::ptrdiff_t;
- static const std::size_t Depth = Base::Depth + 1;
- static const std::size_t DynamicNum = Base::DynamicNum;
- static const size_type CurrentRange = CurRange;
- static const size_type TotalSize =
- Base::TotalSize == dynamic_range ? dynamic_range : CurrentRange * Base::TotalSize;
-
- constexpr BoundsRanges(const std::ptrdiff_t* const arr) : Base(arr) {}
- constexpr BoundsRanges() = default;
-
- template
- constexpr BoundsRanges(const BoundsRanges& other,
- bool firstLevel = true)
- : Base(static_cast&>(other), false)
- {
- GSL_SUPPRESS(type.4) // NO-FORMAT: attribute // TODO: false positive
- (void) firstLevel;
- }
-
- template
- constexpr void serialize(T& arr) const
- {
- arr[Dim] = elementNum();
- this->Base::template serialize(arr);
- }
-
- template
- constexpr size_type linearize(const T& arr) const
- {
- GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
- Expects(arr[Dim] >= 0 && arr[Dim] < CurrentRange); // Index is out of range
- GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
- const ptrdiff_t d = arr[Dim];
- return this->Base::totalSize() * d +
- this->Base::template linearize(arr);
- }
-
- template
- constexpr size_type contains(const T& arr) const
- {
- if (arr[Dim] >= CurrentRange) return -1;
- const size_type last = this->Base::template contains(arr);
- if (last == -1) return -1;
- return this->Base::totalSize() * arr[Dim] + last;
- }
-
- GSL_SUPPRESS(c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used
- constexpr size_type totalSize() const noexcept
- {
- return CurrentRange * this->Base::totalSize();
- }
-
- GSL_SUPPRESS(c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used
- constexpr size_type elementNum() const noexcept
- {
- return CurrentRange;
- }
-
- GSL_SUPPRESS(c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used
- constexpr size_type elementNum(std::size_t dim) const noexcept
- {
- if (dim > 0)
- return this->Base::elementNum(dim - 1);
- else
- return elementNum();
- }
-
- constexpr bool operator==(const BoundsRanges& rhs) const noexcept
- {
- return static_cast(*this) == static_cast(rhs);
- }
- };
-
- template
- struct BoundsRangeConvertible
- : public std::integral_constant= TargetType::TotalSize ||
- TargetType::TotalSize == dynamic_range ||
- SourceType::TotalSize == dynamic_range ||
- TargetType::TotalSize == 0)>
- {
- };
-
- template
- struct TypeListIndexer
- {
- const TypeChain& obj_;
- TypeListIndexer(const TypeChain& obj) : obj_(obj) {}
-
- template
- const TypeChain& getObj(std::true_type)
- {
- return obj_;
- }
-
- template
- auto getObj(std::false_type)
- -> decltype(TypeListIndexer(static_cast(obj_)).template get())
- {
- return TypeListIndexer(static_cast(obj_)).template get();
- }
-
- template
- auto get() -> decltype(getObj(std::integral_constant()))
- {
- return getObj(std::integral_constant());
- }
- };
-
- template
- TypeListIndexer createTypeListIndexer(const TypeChain& obj)
- {
- return TypeListIndexer(obj);
- }
-
- template 1),
- typename Ret = std::enable_if_t>>
- constexpr Ret shift_left(const multi_span_index& other) noexcept
- {
- Ret ret{};
- for (std::size_t i = 0; i < Rank - 1; ++i)
- {
- GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
- ret[i] = other[i + 1];
- }
- return ret;
- }
-} // namespace details
-
-template
-class bounds_iterator;
-
-template
-class static_bounds
-{
-public:
- static_bounds(const details::BoundsRanges&) {}
-};
-
-template
-class static_bounds
-{
- using MyRanges = details::BoundsRanges;
-
- MyRanges m_ranges;
- constexpr static_bounds(const MyRanges& range) noexcept : m_ranges(range) {}
-
- template
- friend class static_bounds;
-
-public:
- static const std::size_t rank = MyRanges::Depth;
- static const std::size_t dynamic_rank = MyRanges::DynamicNum;
- static const std::ptrdiff_t static_size = MyRanges::TotalSize;
-
- using size_type = std::ptrdiff_t;
- using index_type = multi_span_index;
- using const_index_type = std::add_const_t;
- using iterator = bounds_iterator;
- using const_iterator = bounds_iterator;
- using difference_type = std::ptrdiff_t;
- using sliced_type = static_bounds;
- using mapping_type = contiguous_mapping_tag;
-
- constexpr static_bounds() /*noexcept*/ = default;
-
- template
- struct BoundsRangeConvertible2;
-
- template >
- static auto helpBoundsRangeConvertible(SourceType, TargetType, std::true_type) -> Ret;
-
- template
- static auto helpBoundsRangeConvertible(SourceType, TargetType, ...) -> std::false_type;
-
- template
- struct BoundsRangeConvertible2
- : decltype(helpBoundsRangeConvertible(
- SourceType(), TargetType(),
- std::integral_constant()))
- {
- };
-
- template
- struct BoundsRangeConvertible2 : std::true_type
- {
- };
-
- template
- struct BoundsRangeConvertible
- : decltype(helpBoundsRangeConvertible(
- SourceType(), TargetType(),
- std::integral_constant::value ||
- TargetType::CurrentRange == dynamic_range ||
- SourceType::CurrentRange == dynamic_range)>()))
- {
- };
-
- template
- struct BoundsRangeConvertible : std::true_type
- {
- };
-
- template ,
- details::BoundsRanges>::value>>
- constexpr static_bounds(const static_bounds& other) : m_ranges(other.m_ranges)
- {
- Expects((MyRanges::DynamicNum == 0 && details::BoundsRanges::DynamicNum == 0) ||
- MyRanges::DynamicNum > 0 || other.m_ranges.totalSize() >= m_ranges.totalSize());
- }
-
- constexpr static_bounds(std::initializer_list il) : m_ranges(il.begin())
- {
- // Size of the initializer list must match the rank of the array
- Expects((MyRanges::DynamicNum == 0 && il.size() == 1 && *il.begin() == static_size) ||
- MyRanges::DynamicNum == il.size());
- // Size of the range must be less than the max element of the size type
- Expects(m_ranges.totalSize() <= PTRDIFF_MAX);
- }
-
- constexpr sliced_type slice() const noexcept
- {
- return sliced_type{static_cast&>(m_ranges)};
- }
-
- constexpr size_type stride() const noexcept { return rank > 1 ? slice().size() : 1; }
-
- constexpr size_type size() const noexcept { return m_ranges.totalSize(); }
-
- constexpr size_type total_size() const noexcept { return m_ranges.totalSize(); }
-
- constexpr size_type linearize(const index_type& idx) const { return m_ranges.linearize(idx); }
-
- constexpr bool contains(const index_type& idx) const noexcept
- {
- return m_ranges.contains(idx) != -1;
- }
-
- constexpr size_type operator[](std::size_t idx) const noexcept
- {
- return m_ranges.elementNum(idx);
- }
-
- template
- constexpr size_type extent() const noexcept
- {
- static_assert(Dim < rank,
- "dimension should be less than rank (dimension count starts from 0)");
- return details::createTypeListIndexer(m_ranges).template get().elementNum();
- }
-
- template
- constexpr size_type extent(IntType dim) const
- {
- static_assert(std::is_integral::value,
- "Dimension parameter must be supplied as an integral type.");
- auto real_dim = narrow_cast(dim);
- Expects(real_dim < rank);
-
- return m_ranges.elementNum(real_dim);
- }
-
- constexpr index_type index_bounds() const noexcept
- {
- size_type extents[rank] = {};
- m_ranges.serialize(extents);
- return {extents};
- }
-
- template
- constexpr bool operator==(const static_bounds& rhs) const noexcept
- {
- return this->size() == rhs.size();
- }
-
- template
- constexpr bool operator!=(const static_bounds& rhs) const noexcept
- {
- return !(*this == rhs);
- }
-
- constexpr const_iterator begin() const noexcept
- {
- return const_iterator(*this, index_type{});
- }
-
- constexpr const_iterator end() const noexcept
- {
- return const_iterator(*this, this->index_bounds());
- }
-};
-
-template
-class strided_bounds {
- template
- friend class strided_bounds;
-
-public:
- static const std::size_t rank = Rank;
- using value_type = std::ptrdiff_t;
- using reference = std::add_lvalue_reference_t;
- using const_reference = std::add_const_t;
- using size_type = value_type;
- using difference_type = value_type;
- using index_type = multi_span_index;
- using const_index_type = std::add_const_t;
- using iterator = bounds_iterator;
- using const_iterator = bounds_iterator;
- static const value_type dynamic_rank = rank;
- static const value_type static_size = dynamic_range;
- using sliced_type = std::conditional_t, void>;
- using mapping_type = generalized_mapping_tag;
-
- constexpr strided_bounds(const strided_bounds&) noexcept = default;
-
- constexpr strided_bounds& operator=(const strided_bounds&) noexcept = default;
-
- constexpr strided_bounds(const value_type (&values)[rank], index_type strides)
- : m_extents(values), m_strides(std::move(strides))
- {}
-
- constexpr strided_bounds(const index_type& extents, const index_type& strides) noexcept
- : m_extents(extents), m_strides(strides)
- {
- }
-
- constexpr index_type strides() const noexcept { return m_strides; }
-
- GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
- constexpr size_type total_size() const noexcept
- {
- size_type ret = 0;
- for (std::size_t i = 0; i < rank; ++i) { ret += (m_extents[i] - 1) * m_strides[i]; }
- return ret + 1;
- }
-
- GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
- constexpr size_type size() const noexcept
- {
- size_type ret = 1;
- for (std::size_t i = 0; i < rank; ++i) { ret *= m_extents[i]; }
- return ret;
- }
-
- constexpr bool contains(const index_type& idx) const noexcept
- {
- for (std::size_t i = 0; i < rank; ++i)
- {
- if (idx[i] < 0 || idx[i] >= m_extents[i]) return false;
- }
- return true;
- }
-
- GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
- constexpr size_type linearize(const index_type& idx) const
- {
- size_type ret = 0;
- for (std::size_t i = 0; i < rank; i++)
- {
- Expects(idx[i] < m_extents[i]); // index is out of bounds of the array
- ret += idx[i] * m_strides[i];
- }
- return ret;
- }
-
- GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
- constexpr size_type stride() const noexcept { return m_strides[0]; }
-
- template 1), typename Ret = std::enable_if_t>
- constexpr sliced_type slice() const
- {
- return {details::shift_left(m_extents), details::shift_left(m_strides)};
- }
-
- template
-
- GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
- constexpr size_type extent() const noexcept
- {
- static_assert(Dim < Rank,
- "dimension should be less than rank (dimension count starts from 0)");
- return m_extents[Dim];
- }
-
- constexpr index_type index_bounds() const noexcept { return m_extents; }
-
- constexpr const_iterator begin() const noexcept { return const_iterator{*this, index_type{}}; }
-
- constexpr const_iterator end() const noexcept { return const_iterator{*this, index_bounds()}; }
-
-private:
- index_type m_extents;
- index_type m_strides;
-};
-
-template
-struct is_bounds : std::integral_constant
-{
-};
-template
-struct is_bounds> : std::integral_constant