forked from boostorg/core
Compare commits
3 Commits
feature/bi
...
feature/sp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d92a7b0498 | ||
|
|
5f6bb283fb | ||
|
|
6b1d7a91e6 |
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
Copyright 2025 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#undef BOOST_CORE_DETAIL_ASSERT
|
||||
|
||||
#if !defined(__clang__) && \
|
||||
!defined(__INTEL_COMPILER) && \
|
||||
defined(__GNUC__) && \
|
||||
(__GNUC__ < 5)
|
||||
#define BOOST_CORE_DETAIL_ASSERT(expr) void(0)
|
||||
#else
|
||||
#include <boost/assert.hpp>
|
||||
#define BOOST_CORE_DETAIL_ASSERT(expr) BOOST_ASSERT(expr)
|
||||
#endif
|
||||
@@ -8,12 +8,20 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#ifndef BOOST_CORE_SPAN_HPP
|
||||
#define BOOST_CORE_SPAN_HPP
|
||||
|
||||
#include <boost/core/detail/assert.hpp>
|
||||
#include <boost/core/data.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <array>
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_GCC, < 50000)
|
||||
# define BOOST_CORE_SPAN_CONSTEXPR
|
||||
#else
|
||||
# define BOOST_CORE_SPAN_CONSTEXPR constexpr
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
constexpr std::size_t dynamic_extent = static_cast<std::size_t>(-1);
|
||||
@@ -274,19 +282,19 @@ public:
|
||||
return span<T, C>(s_.p + O, C);
|
||||
}
|
||||
|
||||
constexpr span<T, dynamic_extent> first(size_type c) const {
|
||||
return BOOST_CORE_DETAIL_ASSERT(c <= size()),
|
||||
BOOST_CORE_SPAN_CONSTEXPR span<T, dynamic_extent> first(size_type c) const {
|
||||
return BOOST_ASSERT(c <= size()),
|
||||
span<T, dynamic_extent>(s_.p, c);
|
||||
}
|
||||
|
||||
constexpr span<T, dynamic_extent> last(size_type c) const {
|
||||
return BOOST_CORE_DETAIL_ASSERT(c <= size()),
|
||||
BOOST_CORE_SPAN_CONSTEXPR span<T, dynamic_extent> last(size_type c) const {
|
||||
return BOOST_ASSERT(c <= size()),
|
||||
span<T, dynamic_extent>(s_.p + (s_.n - c), c);
|
||||
}
|
||||
|
||||
constexpr span<T, dynamic_extent> subspan(size_type o,
|
||||
BOOST_CORE_SPAN_CONSTEXPR span<T, dynamic_extent> subspan(size_type o,
|
||||
size_type c = dynamic_extent) const {
|
||||
return BOOST_CORE_DETAIL_ASSERT(o <= size() &&
|
||||
return BOOST_ASSERT(o <= size() &&
|
||||
(c == dynamic_extent || c + o <= size())),
|
||||
span<T, dynamic_extent>(s_.p + o,
|
||||
c == dynamic_extent ? s_.n - o : c);
|
||||
@@ -304,16 +312,16 @@ public:
|
||||
return s_.n == 0;
|
||||
}
|
||||
|
||||
constexpr reference operator[](size_type i) const {
|
||||
return BOOST_CORE_DETAIL_ASSERT(i < size()), s_.p[i];
|
||||
BOOST_CORE_SPAN_CONSTEXPR reference operator[](size_type i) const {
|
||||
return BOOST_ASSERT(i < size()), s_.p[i];
|
||||
}
|
||||
|
||||
constexpr reference front() const {
|
||||
return BOOST_CORE_DETAIL_ASSERT(!empty()), *s_.p;
|
||||
BOOST_CORE_SPAN_CONSTEXPR reference front() const {
|
||||
return BOOST_ASSERT(!empty()), *s_.p;
|
||||
}
|
||||
|
||||
constexpr reference back() const {
|
||||
return BOOST_CORE_DETAIL_ASSERT(!empty()), s_.p[s_.n - 1];
|
||||
BOOST_CORE_SPAN_CONSTEXPR reference back() const {
|
||||
return BOOST_ASSERT(!empty()), s_.p[s_.n - 1];
|
||||
}
|
||||
|
||||
constexpr pointer data() const noexcept {
|
||||
@@ -403,4 +411,6 @@ as_writable_bytes(span<T, E> s) noexcept
|
||||
|
||||
} /* boost */
|
||||
|
||||
#undef BOOST_CORE_SPAN_CONSTEXPR
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,8 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_CONSTEXPR)
|
||||
#include <boost/config/workaround.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_CONSTEXPR) && !BOOST_WORKAROUND(BOOST_GCC, < 50000)
|
||||
#include <boost/core/span.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user