chore: update deps

This commit is contained in:
Rim
2025-02-20 06:23:40 -05:00
parent de69a8a5ec
commit 8c7893f668
1045 changed files with 27193 additions and 13903 deletions

View File

@ -17,8 +17,8 @@
#ifndef GSL_ALGORITHM_H
#define GSL_ALGORITHM_H
#include "assert" // for Expects
#include "span" // for dynamic_extent, span
#include "gsl/assert" // for Expects
#include "gsl/span" // for dynamic_extent, span
#include <algorithm> // for copy_n
#include <cstddef> // for ptrdiff_t

View File

@ -19,8 +19,6 @@
#include <type_traits>
// VS2017 15.8 added support for the __cpp_lib_byte definition
// To do: drop _HAS_STD_BYTE when support for pre 15.8 expires
#ifdef _MSC_VER
#pragma warning(push)
@ -31,18 +29,15 @@
#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) || \
(defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603)
#if defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603
#define GSL_USE_STD_BYTE 1
#else // (defined(_HAS_STD_BYTE) && _HAS_STD_BYTE) || (defined(__cpp_lib_byte) && __cpp_lib_byte >=
// 201603)
#else // defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603
#define GSL_USE_STD_BYTE 0
#endif // (defined(_HAS_STD_BYTE) && _HAS_STD_BYTE) || (defined(__cpp_lib_byte) && __cpp_lib_byte >=
// 201603)
#endif // defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603
#endif // GSL_USE_STD_BYTE
#else // _MSC_VER
@ -96,25 +91,25 @@ enum class byte_may_alias byte : unsigned char
{
};
template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>>
template <class IntegerType, std::enable_if_t<std::is_integral<IntegerType>::value, bool> = true>
constexpr byte& operator<<=(byte& b, IntegerType shift) noexcept
{
return b = byte(static_cast<unsigned char>(b) << shift);
}
template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>>
template <class IntegerType, std::enable_if_t<std::is_integral<IntegerType>::value, bool> = true>
constexpr byte operator<<(byte b, IntegerType shift) noexcept
{
return byte(static_cast<unsigned char>(b) << shift);
}
template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>>
template <class IntegerType, std::enable_if_t<std::is_integral<IntegerType>::value, bool> = true>
constexpr byte& operator>>=(byte& b, IntegerType shift) noexcept
{
return b = byte(static_cast<unsigned char>(b) >> shift);
}
template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>>
template <class IntegerType, std::enable_if_t<std::is_integral<IntegerType>::value, bool> = true>
constexpr byte operator>>(byte b, IntegerType shift) noexcept
{
return byte(static_cast<unsigned char>(b) >> shift);
@ -152,7 +147,7 @@ constexpr byte operator^(byte l, byte r) noexcept
constexpr byte operator~(byte b) noexcept { return byte(~static_cast<unsigned char>(b)); }
template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>>
template <class IntegerType, std::enable_if_t<std::is_integral<IntegerType>::value, bool> = true>
constexpr IntegerType to_integer(byte b) noexcept
{
return static_cast<IntegerType>(b);
@ -167,7 +162,7 @@ constexpr byte to_byte(T t) noexcept
{
static_assert(std::is_same<T, unsigned char>::value,
"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<t>() version.");
"If you are calling to_byte with an integer constant use: gsl::to_byte<t>() version.");
return byte(t);
}

View File

@ -17,16 +17,18 @@
#ifndef GSL_GSL_H
#define GSL_GSL_H
#include "algorithm" // copy
#include "assert" // Ensures/Expects
#include "byte" // byte
#include "pointers" // owner, not_null
#include "span" // span
#include "zstring" // zstring
#include "util" // finally()/narrow_cast()...
// IWYU pragma: begin_exports
#include "gsl/algorithm" // copy
#include "gsl/assert" // Ensures/Expects
#include "gsl/byte" // byte
#include "gsl/pointers" // owner, not_null
#include "gsl/span" // span
#include "gsl/zstring" // zstring
#include "gsl/util" // finally()/narrow_cast()...
#ifdef __cpp_exceptions
#include "narrow" // narrow()
#include "gsl/narrow" // narrow()
#endif
// IWYU pragma: end_exports
#endif // GSL_GSL_H

View File

@ -16,8 +16,8 @@
#ifndef GSL_NARROW_H
#define GSL_NARROW_H
#include "assert" // for GSL_SUPPRESS
#include "util" // for narrow_cast
#include "gsl/assert" // for GSL_SUPPRESS
#include "gsl/util" // for narrow_cast
#include <exception> // for std::exception
namespace gsl
{
@ -30,13 +30,12 @@ struct narrowing_error : public std::exception
template <class T, class U, typename std::enable_if<std::is_arithmetic<T>::value>::type* = nullptr>
// clang-format off
GSL_SUPPRESS(type.1) // NO-FORMAT: attribute
GSL_SUPPRESS(f.6) // NO-FORMAT: attribute // TODO: MSVC /analyze does not recognise noexcept(false)
GSL_SUPPRESS(es.46) // NO-FORMAT: attribute // The warning suggests that a floating->unsigned conversion can occur
// in the static_cast below, and that gsl::narrow should be used instead.
// Suppress this warning, since gsl::narrow is defined in terms of
// static_cast
// clang-format on
constexpr T narrow(U u) noexcept(false)
constexpr T narrow(U u)
{
constexpr const bool is_different_signedness =
(std::is_signed<T>::value != std::is_signed<U>::value);
@ -67,9 +66,8 @@ GSL_SUPPRESS(p.2) // NO-FORMAT: attribute // don't rely on undefined behavior
template <class T, class U, typename std::enable_if<!std::is_arithmetic<T>::value>::type* = nullptr>
// clang-format off
GSL_SUPPRESS(type.1) // NO-FORMAT: attribute
GSL_SUPPRESS(f.6) // NO-FORMAT: attribute // TODO: MSVC /analyze does not recognise noexcept(false)
// clang-format on
constexpr T narrow(U u) noexcept(false)
constexpr T narrow(U u)
{
const T t = narrow_cast<T>(u);

View File

@ -17,14 +17,13 @@
#ifndef GSL_POINTERS_H
#define GSL_POINTERS_H
#include "assert" // for Ensures, Expects
#include "gsl/assert" // for Ensures, Expects
#include <algorithm> // for forward
#include <cstddef> // for ptrdiff_t, nullptr_t, size_t
#include <memory> // for shared_ptr, unique_ptr
#include <system_error> // for hash
#include <functional> // for less, greater
#include <memory> // for shared_ptr, unique_ptr, hash
#include <type_traits> // for enable_if_t, is_convertible, is_assignable
#include <utility> // for declval
#include <utility> // for declval, forward
#if !defined(GSL_NO_IOSTREAMS)
#include <iosfwd> // for ostream
@ -76,7 +75,7 @@ using std::unique_ptr;
// T must be a pointer type
// - disallow construction from any type other than pointer type
//
template <class T, class = std::enable_if_t<std::is_pointer<T>::value>>
template <class T, std::enable_if_t<std::is_pointer<T>::value, bool> = true>
using owner = T;
//
@ -118,7 +117,7 @@ public:
not_null(const not_null& other) = default;
not_null& operator=(const not_null& other) = default;
constexpr details::value_or_reference_return_t<T> get() const
noexcept(noexcept(details::value_or_reference_return_t<T>{std::declval<T&>()}))
noexcept(noexcept(details::value_or_reference_return_t<T>(std::declval<T&>())))
{
return ptr_;
}
@ -140,10 +139,18 @@ public:
not_null& operator-=(std::ptrdiff_t) = delete;
void operator[](std::ptrdiff_t) const = delete;
void swap(not_null<T>& other) { std::swap(ptr_, other.ptr_); }
private:
T ptr_;
};
template <typename T, std::enable_if_t<std::is_move_assignable<T>::value && std::is_move_constructible<T>::value, bool> = true>
void swap(not_null<T>& a, not_null<T>& b)
{
a.swap(b);
}
template <class T>
auto make_not_null(T&& t) noexcept
{
@ -268,19 +275,19 @@ class strict_not_null : public not_null<T>
{
public:
template <typename U, typename = std::enable_if_t<std::is_convertible<U, T>::value>>
constexpr explicit strict_not_null(U&& u) : not_null<T>(std::forward<U>(u))
constexpr explicit strict_not_null(U&& u) noexcept(std::is_nothrow_move_constructible<T>::value) : not_null<T>(std::forward<U>(u))
{}
template <typename = std::enable_if_t<!std::is_same<std::nullptr_t, T>::value>>
constexpr explicit strict_not_null(T u) : not_null<T>(u)
constexpr explicit strict_not_null(T u) noexcept(std::is_nothrow_move_constructible<T>::value) : not_null<T>(std::move(u))
{}
template <typename U, typename = std::enable_if_t<std::is_convertible<U, T>::value>>
constexpr strict_not_null(const not_null<U>& other) : not_null<T>(other)
constexpr strict_not_null(const not_null<U>& other) noexcept(std::is_nothrow_move_constructible<T>::value) : not_null<T>(other)
{}
template <typename U, typename = std::enable_if_t<std::is_convertible<U, T>::value>>
constexpr strict_not_null(const strict_not_null<U>& other) : not_null<T>(other)
constexpr strict_not_null(const strict_not_null<U>& other) noexcept(std::is_nothrow_move_constructible<T>::value) : not_null<T>(other)
{}
// To avoid invalidating the "not null" invariant, the contained pointer is actually copied

View File

@ -17,10 +17,10 @@
#ifndef GSL_SPAN_H
#define GSL_SPAN_H
#include "assert" // for Expects
#include "byte" // for byte
#include "span_ext" // for span specialization of gsl::at and other span-related extensions
#include "util" // for narrow_cast
#include "gsl/assert" // for Expects
#include "gsl/byte" // for byte
#include "gsl/span_ext" // for span specialization of gsl::at and other span-related extensions
#include "gsl/util" // for narrow_cast
#include <array> // for array
#include <cstddef> // for ptrdiff_t, size_t, nullptr_t
@ -42,7 +42,7 @@
#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 : 26495) // uninitialized member when constructor calls constructor
#pragma warning(disable : 26446) // parser bug does not allow attributes on some templates
#endif // _MSC_VER
@ -53,7 +53,7 @@
#define GSL_USE_STATIC_CONSTEXPR_WORKAROUND
#endif // !(defined(__cplusplus) && (__cplusplus >= 201703L))
// GCC 7 does not like the signed unsigned missmatch (size_t ptrdiff_t)
// GCC 7 does not like the signed unsigned mismatch (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 indiscriminately, but
// could check if the source value actually doesn't fit into the target type
@ -63,6 +63,14 @@
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
// Turn off clang unsafe buffer warnings as all accessed are guarded by runtime checks
#if defined(__clang__)
#if __has_warning("-Wunsafe-buffer-usage")
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
#endif // __has_warning("-Wunsafe-buffer-usage")
#endif // defined(__clang__)
namespace gsl
{
@ -132,7 +140,9 @@ namespace details
constexpr span_iterator(pointer begin, pointer end, pointer current)
: begin_(begin), end_(end), current_(current)
{}
{
Expects(begin_ <= current_ && current <= end_);
}
constexpr operator span_iterator<const Type>() const noexcept
{
@ -141,21 +151,18 @@ namespace details
constexpr reference operator*() const noexcept
{
Expects(begin_ && end_);
Expects(begin_ <= current_ && current_ < end_);
Expects(current_ != end_);
return *current_;
}
constexpr pointer operator->() const noexcept
{
Expects(begin_ && end_);
Expects(begin_ <= current_ && current_ < end_);
Expects(current_ != end_);
return current_;
}
constexpr span_iterator& operator++() noexcept
{
Expects(begin_ && current_ && end_);
Expects(current_ < end_);
Expects(current_ != end_);
// clang-format off
GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
// clang-format on
@ -172,8 +179,7 @@ namespace details
constexpr span_iterator& operator--() noexcept
{
Expects(begin_ && end_);
Expects(begin_ < current_);
Expects(begin_ != current_);
--current_;
return *this;
}
@ -576,6 +582,8 @@ public:
template <std::size_t Count>
constexpr span<element_type, Count> first() const noexcept
{
static_assert(Extent == dynamic_extent || Count <= Extent,
"first() cannot extract more elements from a span than it contains.");
Expects(Count <= size());
return span<element_type, Count>{data(), Count};
}
@ -586,6 +594,8 @@ public:
// clang-format on
constexpr span<element_type, Count> last() const noexcept
{
static_assert(Extent == dynamic_extent || Count <= Extent,
"last() cannot extract more elements from a span than it contains.");
Expects(Count <= size());
return span<element_type, Count>{data() + (size() - Count), Count};
}
@ -597,6 +607,9 @@ public:
constexpr auto subspan() const noexcept ->
typename details::calculate_subspan_type<ElementType, Extent, Offset, Count>::type
{
static_assert(Extent == dynamic_extent || (Extent >= Offset && (Count == dynamic_extent ||
Count <= Extent - Offset)),
"subspan() cannot extract more elements from a span than it contains.");
Expects((size() >= Offset) && (Count == dynamic_extent || (Count <= size() - Offset)));
using type =
typename details::calculate_subspan_type<ElementType, Extent, Offset, Count>::type;
@ -846,4 +859,10 @@ as_writable_bytes(span<ElementType, Extent> s) noexcept
#pragma GCC diagnostic pop
#endif // __GNUC__ > 6
#if defined(__clang__)
#if __has_warning("-Wunsafe-buffer-usage")
#pragma clang diagnostic pop
#endif // __has_warning("-Wunsafe-buffer-usage")
#endif // defined(__clang__)
#endif // GSL_SPAN_H

View File

@ -27,8 +27,8 @@
//
///////////////////////////////////////////////////////////////////////////////
#include "assert" // GSL_KERNEL_MODE
#include "util" // for narrow_cast, narrow
#include "gsl/assert" // GSL_KERNEL_MODE
#include "gsl/util" // for narrow_cast, narrow
#include <cstddef> // for ptrdiff_t, size_t
#include <utility>

View File

@ -1,4 +0,0 @@
#pragma once
#pragma message( \
"This header will soon be removed. Use <gsl/zstring> instead of <gsl/string_span>")
#include "zstring"

View File

@ -17,7 +17,7 @@
#ifndef GSL_UTIL_H
#define GSL_UTIL_H
#include "assert" // for Expects
#include "gsl/assert" // for Expects
#include <array>
#include <cstddef> // for ptrdiff_t, size_t
@ -40,6 +40,14 @@
#endif // _MSC_VER
// Turn off clang unsafe buffer warnings as all accessed are guarded by runtime checks
#if defined(__clang__)
#if __has_warning("-Wunsafe-buffer-usage")
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
#endif // __has_warning("-Wunsafe-buffer-usage")
#endif // defined(__clang__)
#if defined(__cplusplus) && (__cplusplus >= 201703L)
#define GSL_NODISCARD [[nodiscard]]
#else
@ -138,6 +146,9 @@ GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
return *(cont.begin() + i);
}
template <class T, std::enable_if_t<std::is_move_assignable<T>::value && std::is_move_constructible<T>::value>>
void swap(T& a, T& b) { std::swap(a, b); }
#if defined(__cpp_lib_span) && __cpp_lib_span >= 202002L
template <class T, std::size_t extent = std::dynamic_extent>
constexpr auto at(std::span<T, extent> sp, const index i) -> decltype(sp[sp.size()])
@ -154,4 +165,10 @@ constexpr auto at(std::span<T, extent> sp, const index i) -> decltype(sp[sp.size
#endif // _MSC_VER
#if defined(__clang__)
#if __has_warning("-Wunsafe-buffer-usage")
#pragma clang diagnostic pop
#endif // __has_warning("-Wunsafe-buffer-usage")
#endif // defined(__clang__)
#endif // GSL_UTIL_H

View File

@ -17,7 +17,7 @@
#ifndef GSL_ZSTRING_H
#define GSL_ZSTRING_H
#include "span_ext" // for dynamic_extent
#include "gsl/span_ext" // for dynamic_extent
#include <cstddef> // for size_t, nullptr_t