mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Merge pull request #813 from JordanMaples/dev/jomaples/deprecate_multispan
Deprecate multi_span, strided_span, etc
This commit is contained in:
commit
3d56ba9e7f
@ -23,7 +23,6 @@
|
||||
|
||||
#include <algorithm> // for transform, lexicographical_compare
|
||||
#include <array> // for array
|
||||
#include <cassert>
|
||||
#include <cstddef> // for ptrdiff_t, size_t, nullptr_t
|
||||
#include <cstdint> // for PTRDIFF_MAX
|
||||
#include <functional> // for divides, multiplies, minus, negate, plus
|
||||
@ -49,6 +48,7 @@
|
||||
#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
|
||||
#pragma warning(disable : 4996) // use of function or classes marked [[deprecated]]
|
||||
|
||||
#if _MSC_VER < 1910
|
||||
#pragma push_macro("constexpr")
|
||||
@ -57,6 +57,11 @@
|
||||
#endif // _MSC_VER < 1910
|
||||
#endif // _MSC_VER
|
||||
|
||||
#if __clang__ || __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
// 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
|
||||
@ -76,18 +81,18 @@ namespace gsl
|
||||
namespace details
|
||||
{
|
||||
template <typename SizeType>
|
||||
struct SizeTypeTraits
|
||||
struct [[deprecated]] SizeTypeTraits
|
||||
{
|
||||
static const SizeType max_value = std::numeric_limits<SizeType>::max();
|
||||
};
|
||||
|
||||
template <typename... Ts>
|
||||
class are_integral : public std::integral_constant<bool, true>
|
||||
class [[deprecated]] are_integral : public std::integral_constant<bool, true>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename... Ts>
|
||||
class are_integral<T, Ts...>
|
||||
class [[deprecated]] are_integral<T, Ts...>
|
||||
: public std::integral_constant<bool,
|
||||
std::is_integral<T>::value && are_integral<Ts...>::value>
|
||||
{
|
||||
@ -95,8 +100,7 @@ namespace details
|
||||
} // namespace details
|
||||
|
||||
template <std::size_t Rank>
|
||||
class multi_span_index final
|
||||
{
|
||||
class [[deprecated]] multi_span_index final {
|
||||
static_assert(Rank > 0, "Rank must be greater than 0!");
|
||||
|
||||
template <std::size_t OtherRank>
|
||||
@ -152,10 +156,7 @@ public:
|
||||
return std::equal(elems, elems + rank, rhs.elems);
|
||||
}
|
||||
|
||||
constexpr bool operator!=(const multi_span_index& rhs) const
|
||||
{
|
||||
return !(*this == rhs);
|
||||
}
|
||||
constexpr bool operator!=(const multi_span_index& rhs) const { return !(*this == rhs); }
|
||||
|
||||
constexpr multi_span_index operator+() const noexcept { return *this; }
|
||||
|
||||
@ -184,8 +185,7 @@ public:
|
||||
{
|
||||
GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
|
||||
GSL_SUPPRESS(bounds.3) // NO-FORMAT: attribute
|
||||
std::transform(elems, elems + rank, rhs.elems, elems,
|
||||
std::plus<value_type>{});
|
||||
std::transform(elems, elems + rank, rhs.elems, elems, std::plus<value_type>{});
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -240,7 +240,7 @@ private:
|
||||
|
||||
#if !defined(_MSC_VER) || _MSC_VER >= 1910
|
||||
|
||||
struct static_bounds_dynamic_range_t
|
||||
struct [[deprecated]] static_bounds_dynamic_range_t
|
||||
{
|
||||
template <typename T, typename = std::enable_if_t<std::is_integral<T>::value>>
|
||||
constexpr operator T() const noexcept
|
||||
@ -288,25 +288,22 @@ constexpr static_bounds_dynamic_range_t dynamic_range{};
|
||||
const std::ptrdiff_t dynamic_range = -1;
|
||||
#endif
|
||||
|
||||
struct generalized_mapping_tag
|
||||
{
|
||||
};
|
||||
struct contiguous_mapping_tag : generalized_mapping_tag
|
||||
struct [[deprecated]] generalized_mapping_tag
|
||||
{
|
||||
};
|
||||
struct[[deprecated]] contiguous_mapping_tag : generalized_mapping_tag{};
|
||||
|
||||
namespace details
|
||||
{
|
||||
|
||||
template <std::ptrdiff_t Left, std::ptrdiff_t Right>
|
||||
struct LessThan
|
||||
struct [[deprecated]] LessThan
|
||||
{
|
||||
static const bool value = Left < Right;
|
||||
};
|
||||
|
||||
template <std::ptrdiff_t... Ranges>
|
||||
struct BoundsRanges
|
||||
{
|
||||
struct [[deprecated]] BoundsRanges {
|
||||
using size_type = std::ptrdiff_t;
|
||||
static const size_type Depth = 0;
|
||||
static const size_type DynamicNum = 0;
|
||||
@ -345,7 +342,7 @@ namespace details
|
||||
};
|
||||
|
||||
template <std::ptrdiff_t... RestRanges>
|
||||
struct BoundsRanges<dynamic_range, RestRanges...> : BoundsRanges<RestRanges...>
|
||||
struct[[deprecated]] BoundsRanges<dynamic_range, RestRanges...> : BoundsRanges<RestRanges...>
|
||||
{
|
||||
using Base = BoundsRanges<RestRanges...>;
|
||||
using size_type = std::ptrdiff_t;
|
||||
@ -358,7 +355,8 @@ namespace details
|
||||
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(
|
||||
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())
|
||||
@ -400,19 +398,19 @@ namespace details
|
||||
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 totalSize() const noexcept { return m_bound; }
|
||||
|
||||
GSL_SUPPRESS(c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used
|
||||
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
|
||||
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)
|
||||
@ -429,7 +427,7 @@ namespace details
|
||||
};
|
||||
|
||||
template <std::ptrdiff_t CurRange, std::ptrdiff_t... RestRanges>
|
||||
struct BoundsRanges<CurRange, RestRanges...> : BoundsRanges<RestRanges...>
|
||||
struct[[deprecated]] BoundsRanges<CurRange, RestRanges...> : BoundsRanges<RestRanges...>
|
||||
{
|
||||
using Base = BoundsRanges<RestRanges...>;
|
||||
using size_type = std::ptrdiff_t;
|
||||
@ -465,8 +463,7 @@ namespace details
|
||||
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<T, Dim + 1>(arr);
|
||||
return this->Base::totalSize() * d + this->Base::template linearize<T, Dim + 1>(arr);
|
||||
}
|
||||
|
||||
template <typename T, std::size_t Dim = 0>
|
||||
@ -478,19 +475,19 @@ namespace details
|
||||
return this->Base::totalSize() * arr[Dim] + last;
|
||||
}
|
||||
|
||||
GSL_SUPPRESS(c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used
|
||||
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() const noexcept { return CurrentRange; }
|
||||
|
||||
GSL_SUPPRESS(c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used
|
||||
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)
|
||||
@ -506,17 +503,14 @@ namespace details
|
||||
};
|
||||
|
||||
template <typename SourceType, typename TargetType>
|
||||
struct BoundsRangeConvertible
|
||||
struct[[deprecated]] BoundsRangeConvertible
|
||||
: public std::integral_constant<bool, (SourceType::TotalSize >= TargetType::TotalSize ||
|
||||
TargetType::TotalSize == dynamic_range ||
|
||||
SourceType::TotalSize == dynamic_range ||
|
||||
TargetType::TotalSize == 0)>
|
||||
{
|
||||
};
|
||||
TargetType::TotalSize == 0)>{};
|
||||
|
||||
template <typename TypeChain>
|
||||
struct TypeListIndexer
|
||||
{
|
||||
struct [[deprecated]] TypeListIndexer {
|
||||
const TypeChain& obj_;
|
||||
constexpr TypeListIndexer(const TypeChain& obj) : obj_(obj) {}
|
||||
|
||||
@ -562,17 +556,16 @@ namespace details
|
||||
} // namespace details
|
||||
|
||||
template <typename IndexType>
|
||||
class bounds_iterator;
|
||||
class [[deprecated]] bounds_iterator;
|
||||
|
||||
template <std::ptrdiff_t... Ranges>
|
||||
class static_bounds
|
||||
{
|
||||
class [[deprecated]] static_bounds {
|
||||
public:
|
||||
static_bounds(const details::BoundsRanges<Ranges...>&) {}
|
||||
};
|
||||
|
||||
template <std::ptrdiff_t FirstRange, std::ptrdiff_t... RestRanges>
|
||||
class static_bounds<FirstRange, RestRanges...>
|
||||
class[[deprecated]] static_bounds<FirstRange, RestRanges...>
|
||||
{
|
||||
using MyRanges = details::BoundsRanges<FirstRange, RestRanges...>;
|
||||
|
||||
@ -724,10 +717,7 @@ public:
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
constexpr const_iterator begin() const noexcept
|
||||
{
|
||||
return const_iterator(*this, index_type{});
|
||||
}
|
||||
constexpr const_iterator begin() const noexcept { return const_iterator(*this, index_type{}); }
|
||||
|
||||
constexpr const_iterator end() const noexcept
|
||||
{
|
||||
@ -736,7 +726,7 @@ public:
|
||||
};
|
||||
|
||||
template <std::size_t Rank>
|
||||
class strided_bounds {
|
||||
class [[deprecated]] strided_bounds {
|
||||
template <std::size_t OtherRank>
|
||||
friend class strided_bounds;
|
||||
|
||||
@ -766,8 +756,7 @@ public:
|
||||
|
||||
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; }
|
||||
|
||||
@ -839,21 +828,14 @@ private:
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_bounds : std::integral_constant<bool, false>
|
||||
{
|
||||
};
|
||||
struct[[deprecated]] is_bounds : std::integral_constant<bool, false>{};
|
||||
template <std::ptrdiff_t... Ranges>
|
||||
struct is_bounds<static_bounds<Ranges...>> : std::integral_constant<bool, true>
|
||||
{
|
||||
};
|
||||
struct[[deprecated]] is_bounds<static_bounds<Ranges...>> : std::integral_constant<bool, true>{};
|
||||
template <std::size_t Rank>
|
||||
struct is_bounds<strided_bounds<Rank>> : std::integral_constant<bool, true>
|
||||
{
|
||||
};
|
||||
struct[[deprecated]] is_bounds<strided_bounds<Rank>> : std::integral_constant<bool, true>{};
|
||||
|
||||
template <typename IndexType>
|
||||
class bounds_iterator
|
||||
{
|
||||
class [[deprecated]] bounds_iterator {
|
||||
public:
|
||||
static const std::size_t rank = IndexType::rank;
|
||||
using iterator_category = std::random_access_iterator_tag;
|
||||
@ -974,7 +956,6 @@ public:
|
||||
return curr_ == rhs.curr_;
|
||||
}
|
||||
|
||||
|
||||
constexpr bool operator!=(const bounds_iterator& rhs) const noexcept { return !(*this == rhs); }
|
||||
|
||||
constexpr bool operator<(const bounds_iterator& rhs) const noexcept
|
||||
@ -995,7 +976,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
|
||||
constexpr bool less(index_type & one, index_type & other) const noexcept
|
||||
{
|
||||
@ -1092,17 +1072,17 @@ namespace details
|
||||
} // namespace details
|
||||
|
||||
template <typename Span>
|
||||
class contiguous_span_iterator;
|
||||
class [[deprecated]] contiguous_span_iterator;
|
||||
template <typename Span>
|
||||
class general_span_iterator;
|
||||
class [[deprecated]] general_span_iterator;
|
||||
|
||||
template <std::ptrdiff_t DimSize = dynamic_range>
|
||||
struct dim_t
|
||||
struct [[deprecated]] dim_t
|
||||
{
|
||||
static const std::ptrdiff_t value = DimSize;
|
||||
};
|
||||
template <>
|
||||
struct dim_t<dynamic_range>
|
||||
struct [[deprecated]] dim_t<dynamic_range>
|
||||
{
|
||||
static const std::ptrdiff_t value = dynamic_range;
|
||||
const std::ptrdiff_t dvalue;
|
||||
@ -1123,28 +1103,30 @@ constexpr dim_t<N> dim(std::ptrdiff_t n) noexcept
|
||||
|
||||
template <typename ValueType, std::ptrdiff_t FirstDimension = dynamic_range,
|
||||
std::ptrdiff_t... RestDimensions>
|
||||
class multi_span;
|
||||
class [[deprecated("gsl::multi_span is deprecated because it is not in the C++ Core Guidelines")]] multi_span;
|
||||
|
||||
template <typename ValueType, std::size_t Rank>
|
||||
class strided_span;
|
||||
class [[deprecated("gsl::strided_span is deprecated because it is not in the C++ Core Guidelines")]] strided_span;
|
||||
|
||||
namespace details
|
||||
{
|
||||
template <typename T, typename = std::true_type>
|
||||
struct SpanTypeTraits
|
||||
struct [[deprecated]] SpanTypeTraits
|
||||
{
|
||||
using value_type = T;
|
||||
using size_type = std::size_t;
|
||||
};
|
||||
|
||||
template <typename Traits>
|
||||
struct SpanTypeTraits<Traits, typename std::is_reference<typename Traits::span_traits&>::type>
|
||||
struct [[deprecated]] SpanTypeTraits<
|
||||
Traits, typename std::is_reference<typename Traits::span_traits&>::type>
|
||||
{
|
||||
using value_type = typename Traits::span_traits::value_type;
|
||||
using size_type = typename Traits::span_traits::size_type;
|
||||
};
|
||||
|
||||
template <typename T, std::ptrdiff_t... Ranks>
|
||||
struct SpanArrayTraits
|
||||
struct [[deprecated]] SpanArrayTraits
|
||||
{
|
||||
using type = multi_span<T, Ranks...>;
|
||||
using value_type = T;
|
||||
@ -1153,7 +1135,7 @@ namespace details
|
||||
using reference = T&;
|
||||
};
|
||||
template <typename T, std::ptrdiff_t N, std::ptrdiff_t... Ranks>
|
||||
struct SpanArrayTraits<T[N], Ranks...> : SpanArrayTraits<T, Ranks..., N>
|
||||
struct [[deprecated]] SpanArrayTraits<T[N], Ranks...> : SpanArrayTraits<T, Ranks..., N>
|
||||
{
|
||||
};
|
||||
|
||||
@ -1177,7 +1159,7 @@ namespace details
|
||||
totalSize, std::integral_constant<bool, BoundsType::dynamic_rank == 1>());
|
||||
}
|
||||
|
||||
struct Sep
|
||||
struct [[deprecated]] Sep
|
||||
{
|
||||
};
|
||||
|
||||
@ -1200,36 +1182,35 @@ namespace details
|
||||
}
|
||||
|
||||
template <typename... Dimensions>
|
||||
struct static_as_multi_span_static_bounds_helper
|
||||
struct [[deprecated]] static_as_multi_span_static_bounds_helper
|
||||
{
|
||||
using type = static_bounds<(Dimensions::value)...>;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_multi_span_oracle : std::false_type
|
||||
struct [[deprecated]] is_multi_span_oracle : std::false_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename ValueType, std::ptrdiff_t FirstDimension, std::ptrdiff_t... RestDimensions>
|
||||
struct is_multi_span_oracle<multi_span<ValueType, FirstDimension, RestDimensions...>>
|
||||
struct [[deprecated]] is_multi_span_oracle<multi_span<ValueType, FirstDimension, RestDimensions...>>
|
||||
: std::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename ValueType, std::ptrdiff_t Rank>
|
||||
struct is_multi_span_oracle<strided_span<ValueType, Rank>> : std::true_type
|
||||
struct [[deprecated]] is_multi_span_oracle<strided_span<ValueType, Rank>> : std::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_multi_span : is_multi_span_oracle<std::remove_cv_t<T>>
|
||||
struct [[deprecated]] is_multi_span : is_multi_span_oracle<std::remove_cv_t<T>>
|
||||
{
|
||||
};
|
||||
} // namespace details
|
||||
|
||||
template <typename ValueType, std::ptrdiff_t FirstDimension, std::ptrdiff_t... RestDimensions>
|
||||
class multi_span
|
||||
{
|
||||
class [[deprecated("gsl::multi_span is deprecated because it is not in the C++ Core Guidelines")]] multi_span {
|
||||
// TODO do we still need this?
|
||||
template <typename ValueType2, std::ptrdiff_t FirstDimension2,
|
||||
std::ptrdiff_t... RestDimensions2>
|
||||
@ -1262,8 +1243,7 @@ private:
|
||||
public:
|
||||
// default constructor - same as constructing from nullptr_t
|
||||
GSL_SUPPRESS(type.6) // NO-FORMAT: attribute // TODO: false positive
|
||||
constexpr multi_span() noexcept
|
||||
: multi_span(nullptr, bounds_type{})
|
||||
constexpr multi_span() noexcept : multi_span(nullptr, bounds_type{})
|
||||
{
|
||||
static_assert(bounds_type::dynamic_rank != 0 ||
|
||||
(bounds_type::dynamic_rank == 0 && bounds_type::static_size == 0),
|
||||
@ -1273,8 +1253,7 @@ public:
|
||||
|
||||
// construct from nullptr - get an empty multi_span
|
||||
GSL_SUPPRESS(type.6) // NO-FORMAT: attribute // TODO: false positive
|
||||
constexpr multi_span(std::nullptr_t) noexcept
|
||||
: multi_span(nullptr, bounds_type{})
|
||||
constexpr multi_span(std::nullptr_t) noexcept : multi_span(nullptr, bounds_type{})
|
||||
{
|
||||
static_assert(bounds_type::dynamic_rank != 0 ||
|
||||
(bounds_type::dynamic_rank == 0 && bounds_type::static_size == 0),
|
||||
@ -1298,8 +1277,7 @@ public:
|
||||
// construct from a single element
|
||||
|
||||
GSL_SUPPRESS(type.6) // NO-FORMAT: attribute // TODO: false positive
|
||||
constexpr multi_span(reference data) noexcept
|
||||
: multi_span(&data, bounds_type{1})
|
||||
constexpr multi_span(reference data) noexcept : multi_span(&data, bounds_type{1})
|
||||
{
|
||||
static_assert(bounds_type::dynamic_rank > 0 || bounds_type::static_size == 0 ||
|
||||
bounds_type::static_size == 1,
|
||||
@ -1312,13 +1290,10 @@ public:
|
||||
|
||||
// construct from pointer + length
|
||||
GSL_SUPPRESS(type.6) // NO-FORMAT: attribute // TODO: false positive
|
||||
constexpr multi_span(pointer ptr, size_type size)
|
||||
: multi_span(ptr, bounds_type{size})
|
||||
{}
|
||||
constexpr multi_span(pointer ptr, size_type size) : multi_span(ptr, bounds_type{size}) {}
|
||||
|
||||
// construct from pointer + length - multidimensional
|
||||
constexpr multi_span(pointer data, bounds_type bounds)
|
||||
: data_(data), bounds_(std::move(bounds))
|
||||
constexpr multi_span(pointer data, bounds_type bounds) : data_(data), bounds_(std::move(bounds))
|
||||
{
|
||||
Expects((bounds_.size() > 0 && data != nullptr) || bounds_.size() == 0);
|
||||
}
|
||||
@ -1493,8 +1468,7 @@ public:
|
||||
}
|
||||
|
||||
// section - creates a non-contiguous, strided multi_span from a contiguous one
|
||||
constexpr strided_span<ValueType, Rank> section(index_type origin,
|
||||
index_type extents) const
|
||||
constexpr strided_span<ValueType, Rank> section(index_type origin, index_type extents) const
|
||||
{
|
||||
const size_type size = this->bounds().total_size() - this->bounds().linearize(origin);
|
||||
return {&this->operator[](origin), size,
|
||||
@ -1636,8 +1610,8 @@ public:
|
||||
template <typename OtherValueType, std::ptrdiff_t... OtherDimensions,
|
||||
typename = std::enable_if_t<std::is_same<std::remove_cv_t<value_type>,
|
||||
std::remove_cv_t<OtherValueType>>::value>>
|
||||
constexpr bool operator>(const multi_span<OtherValueType, OtherDimensions...>& other) const
|
||||
noexcept
|
||||
constexpr bool operator>(const multi_span<OtherValueType, OtherDimensions...>& other)
|
||||
const noexcept
|
||||
{
|
||||
return (other < *this);
|
||||
}
|
||||
@ -1673,7 +1647,8 @@ constexpr auto as_multi_span(SpanType s, Dimensions2... dims)
|
||||
|
||||
// convert a multi_span<T> to a multi_span<const byte>
|
||||
template <typename U, std::ptrdiff_t... Dimensions>
|
||||
multi_span<const byte, dynamic_range> as_bytes(multi_span<U, Dimensions...> s) noexcept
|
||||
multi_span<const byte, dynamic_range>
|
||||
as_bytes(multi_span<U, Dimensions...> s) noexcept
|
||||
{
|
||||
static_assert(std::is_trivial<std::decay_t<U>>::value,
|
||||
"The value_type of multi_span must be a trivial type.");
|
||||
@ -1759,7 +1734,8 @@ constexpr auto as_multi_span(T* arr, std::ptrdiff_t len) ->
|
||||
}
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
constexpr auto as_multi_span(T (&arr)[N]) -> typename details::SpanArrayTraits<T, N>::type
|
||||
constexpr auto as_multi_span(T (&arr)[N]) ->
|
||||
typename details::SpanArrayTraits<T, N>::type
|
||||
{
|
||||
return {arr};
|
||||
}
|
||||
@ -1812,7 +1788,7 @@ constexpr auto as_multi_span(std::basic_string<CharT, Traits, Allocator>& str)
|
||||
// strided_span is an extension that is not strictly part of the GSL at this time.
|
||||
// It is kept here while the multidimensional interface is still being defined.
|
||||
template <typename ValueType, std::size_t Rank>
|
||||
class strided_span
|
||||
class [[deprecated("gsl::strided_span is deprecated because it is not in the C++ Core Guidelines")]] strided_span
|
||||
{
|
||||
public:
|
||||
using bounds_type = strided_bounds<Rank>;
|
||||
@ -2055,8 +2031,7 @@ private:
|
||||
};
|
||||
|
||||
template <class Span>
|
||||
class contiguous_span_iterator
|
||||
{
|
||||
class [[deprecated]] contiguous_span_iterator {
|
||||
public:
|
||||
using iterator_category = std::random_access_iterator_tag;
|
||||
using value_type = typename Span::value_type;
|
||||
@ -2072,7 +2047,8 @@ private:
|
||||
const Span* m_validator;
|
||||
|
||||
GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
|
||||
void validateThis() const {
|
||||
void validateThis() const
|
||||
{
|
||||
// iterator is out of range of the array
|
||||
Expects(data_ >= m_validator->data_ && data_ < m_validator->data_ + m_validator->size());
|
||||
}
|
||||
@ -2176,7 +2152,7 @@ contiguous_span_iterator<Span> operator+(typename contiguous_span_iterator<Span>
|
||||
}
|
||||
|
||||
template <typename Span>
|
||||
class general_span_iterator {
|
||||
class [[deprecated]] general_span_iterator {
|
||||
public:
|
||||
using iterator_category = std::random_access_iterator_tag;
|
||||
using value_type = typename Span::value_type;
|
||||
@ -2290,4 +2266,8 @@ general_span_iterator<Span> operator+(typename general_span_iterator<Span>::diff
|
||||
#pragma GCC diagnostic pop
|
||||
#endif // __GNUC__ > 6
|
||||
|
||||
#if __clang__ || __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif // GSL_MULTI_SPAN_H
|
||||
|
@ -18,6 +18,12 @@
|
||||
// blanket turn off warnings from CppCoreCheck from catch
|
||||
// so people aren't annoyed by them when running the tool.
|
||||
#pragma warning(disable : 26440 26426) // from catch
|
||||
#pragma warning(disable : 4996) // use of function or classes marked [[deprecated]]
|
||||
#endif
|
||||
|
||||
#if __clang__ || __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
#include <catch/catch.hpp> // for AssertionHandler, StringRef, TEST_CASE
|
||||
@ -113,3 +119,7 @@ TEST_CASE("bounds_convertible")
|
||||
#ifdef CONFIRM_COMPILATION_ERRORS
|
||||
copy(src_span_static, dst_span_static);
|
||||
#endif
|
||||
|
||||
#if __clang__ || __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
@ -18,7 +18,13 @@
|
||||
// blanket turn off warnings from CppCoreCheck from catch
|
||||
// so people aren't annoyed by them when running the tool.
|
||||
#pragma warning(disable : 26440 26426) // from catch
|
||||
#pragma warning(disable : 4996) // multi_span is in the process of being deprecated.
|
||||
// Suppressing warnings until it is completely removed
|
||||
#endif
|
||||
|
||||
#if __clang__ || __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
#include <catch/catch.hpp> // for AssertionHandler, StringRef, CHECK, CHECK...
|
||||
@ -1787,3 +1793,7 @@ TEST_CASE("iterator")
|
||||
#ifdef CONFIRM_COMPILATION_ERRORS
|
||||
copy(src_span_static, dst_span_static);
|
||||
#endif
|
||||
|
||||
#if __clang__ || __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
@ -17,8 +17,14 @@
|
||||
#ifdef _MSC_VER
|
||||
// blanket turn off warnings from CppCoreCheck from catch
|
||||
// so people aren't annoyed by them when running the tool.
|
||||
#pragma warning(disable : 26440 26426) // from catch
|
||||
#pragma warning(disable : 26440 26426) // from catch deprecated
|
||||
#pragma warning(disable : 4996) // strided_span is in the process of being deprecated.
|
||||
// Suppressing warnings until it is completely removed
|
||||
#endif
|
||||
|
||||
#if __clang__ || __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
#include <catch/catch.hpp> // for AssertionHandler, StringRef, CHECK, CHECK...
|
||||
@ -794,3 +800,7 @@ TEST_CASE("strided_span_conversion")
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
#if __clang__ || __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user