Skip to content

Commit

Permalink
Update doctest to v2.4.11
Browse files Browse the repository at this point in the history
Update spanlite to v0.11.0
Update stringview to v1.4.8
  • Loading branch information
Ghabry committed Jan 3, 2025
1 parent 83240a0 commit 8d886b4
Show file tree
Hide file tree
Showing 3 changed files with 2,131 additions and 1,378 deletions.
85 changes: 74 additions & 11 deletions src/lcf/third_party/span.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Based on http://wg21.link/p0122r7
// For more information see https://github.com/martinmoene/span-lite
//
// Copyright 2018-2020 Martin Moene
// Copyright 2018-2021 Martin Moene
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -12,7 +12,7 @@
#define NONSTD_SPAN_HPP_INCLUDED

#define span_lite_MAJOR 0
#define span_lite_MINOR 10
#define span_lite_MINOR 11
#define span_lite_PATCH 0

#define span_lite_VERSION span_STRINGIFY(span_lite_MAJOR) "." span_STRINGIFY(span_lite_MINOR) "." span_STRINGIFY(span_lite_PATCH)
Expand Down Expand Up @@ -60,6 +60,10 @@

// span configuration (features):

#ifndef span_FEATURE_WITH_INITIALIZER_LIST_P2447
# define span_FEATURE_WITH_INITIALIZER_LIST_P2447 0
#endif

#ifndef span_FEATURE_WITH_CONTAINER
#ifdef span_FEATURE_WITH_CONTAINER_TO_STD
# define span_FEATURE_WITH_CONTAINER span_IN_STD( span_FEATURE_WITH_CONTAINER_TO_STD )
Expand Down Expand Up @@ -171,7 +175,7 @@
# error Please define none or one of span_CONFIG_CONTRACT_VIOLATION_THROWS and span_CONFIG_CONTRACT_VIOLATION_TERMINATES to 1, but not both.
#endif

// C++ language version detection (C++20 is speculative):
// C++ language version detection (C++23 is speculative):
// Note: VC14.0/1900 (VS2015) lacks too much from C++14.

#ifndef span_CPLUSPLUS
Expand All @@ -186,7 +190,8 @@
#define span_CPP11_OR_GREATER ( span_CPLUSPLUS >= 201103L )
#define span_CPP14_OR_GREATER ( span_CPLUSPLUS >= 201402L )
#define span_CPP17_OR_GREATER ( span_CPLUSPLUS >= 201703L )
#define span_CPP20_OR_GREATER ( span_CPLUSPLUS >= 202000L )
#define span_CPP20_OR_GREATER ( span_CPLUSPLUS >= 202002L )
#define span_CPP23_OR_GREATER ( span_CPLUSPLUS >= 202300L )

// C++ language version (represent 98 as 3):

Expand Down Expand Up @@ -223,6 +228,7 @@
namespace nonstd {

using std::span;
using std::dynamic_extent;

// Note: C++20 does not provide comparison
// using std::operator==;
Expand Down Expand Up @@ -340,6 +346,7 @@ span_DISABLE_MSVC_WARNINGS( 26439 26440 26472 26473 26481 26490 )
#define span_HAVE_IS_DEFAULT span_CPP11_140
#define span_HAVE_IS_DELETE span_CPP11_140
#define span_HAVE_NOEXCEPT span_CPP11_140
#define span_HAVE_NORETURN ( span_CPP11_140 && ! span_BETWEEN( span_COMPILER_GNUC_VERSION, 1, 480 ) )
#define span_HAVE_NULLPTR span_CPP11_100
#define span_HAVE_STATIC_ASSERT span_CPP11_100

Expand All @@ -351,7 +358,6 @@ span_DISABLE_MSVC_WARNINGS( 26439 26440 26472 26473 26481 26490 )

#define span_HAVE_DEPRECATED span_CPP17_000
#define span_HAVE_NODISCARD span_CPP17_000
#define span_HAVE_NORETURN span_CPP17_000

// MSVC: template parameter deduction guides since Visual Studio 2017 v15.7

Expand Down Expand Up @@ -707,7 +713,7 @@ namespace detail {
/*enum*/ struct enabler{};

template< typename T >
bool is_positive( T x )
span_constexpr bool is_positive( T x )
{
return std11::is_signed<T>::value ? x >= 0 : true;
}
Expand Down Expand Up @@ -816,7 +822,7 @@ struct is_compatible_container : std::true_type{};
# pragma GCC diagnostic ignored "-Wlong-long"
#endif

inline void throw_out_of_range( size_t idx, size_t size )
span_noreturn inline void throw_out_of_range( size_t idx, size_t size )
{
const char fmt[] = "span::at(): index '%lli' is out of range [0..%lli)";
char buffer[ 2 * 20 + sizeof fmt ];
Expand All @@ -827,7 +833,7 @@ inline void throw_out_of_range( size_t idx, size_t size )

#else // MEMBER_AT

inline void throw_out_of_range( size_t /*idx*/, size_t /*size*/ )
span_noreturn inline void throw_out_of_range( size_t /*idx*/, size_t /*size*/ )
{
throw std::out_of_range( "span::at(): index outside span" );
}
Expand Down Expand Up @@ -953,7 +959,7 @@ class span
#if span_HAVE( ITERATOR_CTOR )
template< typename It, typename End
span_REQUIRES_T((
std::is_convertible<decltype(*std::declval<It&>()), element_type &>::value
std::is_convertible<decltype(&*std::declval<It&>()), element_type *>::value
&& ! std::is_convertible<End, std::size_t>::value
))
>
Expand Down Expand Up @@ -1058,6 +1064,52 @@ class span
{}
#endif

#if span_FEATURE( WITH_INITIALIZER_LIST_P2447 ) && span_HAVE( INITIALIZER_LIST )

// constexpr explicit(extent != dynamic_extent) span(std::initializer_list<value_type> il) noexcept;

#if !span_BETWEEN( span_COMPILER_MSVC_VERSION, 120, 130 )

template< extent_t U = Extent
span_REQUIRES_T((
U != dynamic_extent
))
>
#if span_COMPILER_GNUC_VERSION >= 900 // prevent GCC's "-Winit-list-lifetime"
span_constexpr14 explicit span( std::initializer_list<value_type> il ) span_noexcept
{
data_ = il.begin();
size_ = il.size();
}
#else
span_constexpr explicit span( std::initializer_list<value_type> il ) span_noexcept
: data_( il.begin() )
, size_( il.size() )
{}
#endif

#endif // MSVC 120 (VS2013)

template< extent_t U = Extent
span_REQUIRES_T((
U == dynamic_extent
))
>
#if span_COMPILER_GNUC_VERSION >= 900 // prevent GCC's "-Winit-list-lifetime"
span_constexpr14 /*explicit*/ span( std::initializer_list<value_type> il ) span_noexcept
{
data_ = il.begin();
size_ = il.size();
}
#else
span_constexpr /*explicit*/ span( std::initializer_list<value_type> il ) span_noexcept
: data_( il.begin() )
, size_( il.size() )
{}
#endif

#endif // P2447

#if span_HAVE( IS_DEFAULT )
span_constexpr span( span const & other ) span_noexcept = default;

Expand All @@ -1084,12 +1136,12 @@ class span

template< class OtherElementType, extent_type OtherExtent
span_REQUIRES_T((
(Extent == dynamic_extent || Extent == OtherExtent)
(Extent == dynamic_extent || OtherExtent == dynamic_extent || Extent == OtherExtent)
&& std::is_convertible<OtherElementType(*)[], element_type(*)[]>::value
))
>
span_constexpr_exp span( span<OtherElementType, OtherExtent> const & other ) span_noexcept
: data_( reinterpret_cast<pointer>( other.data() ) )
: data_( other.data() )
, size_( other.size() )
{
span_EXPECTS( OtherExtent == dynamic_extent || other.size() == to_size(OtherExtent) );
Expand Down Expand Up @@ -1587,6 +1639,17 @@ make_span( std::array< T, N > const & arr ) span_noexcept

#endif // span_HAVE( ARRAY )

#if span_USES_STD_SPAN || span_HAVE( INITIALIZER_LIST )

template< class T >
inline span_constexpr span< const T >
make_span( std::initializer_list<T> il ) span_noexcept
{
return span<const T>( il.begin(), il.size() );
}

#endif // span_HAVE( INITIALIZER_LIST )

#if span_USES_STD_SPAN

template< class Container, class EP = decltype( std::data(std::declval<Container&>())) >
Expand Down
Loading

0 comments on commit 8d886b4

Please sign in to comment.