mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
initial deprecation of multi_span and strided_span
This commit is contained in:
parent
1046c9d247
commit
bbeb0bdc91
@ -49,13 +49,14 @@
|
|||||||
#pragma warning(disable : 26473) // in some instantiations we cast to the same type
|
#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 : 26490) // TODO: bug in parser - attributes and templates
|
||||||
#pragma warning(disable : 26465) // TODO: bug - suppression does not work on template functions
|
#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
|
#if _MSC_VER < 1910
|
||||||
#pragma push_macro("constexpr")
|
#pragma push_macro("constexpr")
|
||||||
#define constexpr /*constexpr*/
|
#define constexpr /*constexpr*/
|
||||||
|
|
||||||
#endif // _MSC_VER < 1910
|
#endif // _MSC_VER < 1910
|
||||||
#endif // _MSC_VER
|
#endif // _MSC_VER
|
||||||
|
|
||||||
// GCC 7 does not like the signed unsigned missmatch (size_t ptrdiff_t)
|
// 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
|
// While there is a conversion from signed to unsigned, it happens at
|
||||||
@ -95,8 +96,7 @@ namespace details
|
|||||||
} // namespace details
|
} // namespace details
|
||||||
|
|
||||||
template <std::size_t Rank>
|
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!");
|
static_assert(Rank > 0, "Rank must be greater than 0!");
|
||||||
|
|
||||||
template <std::size_t OtherRank>
|
template <std::size_t OtherRank>
|
||||||
@ -111,7 +111,7 @@ public:
|
|||||||
|
|
||||||
constexpr multi_span_index() noexcept {}
|
constexpr multi_span_index() noexcept {}
|
||||||
|
|
||||||
constexpr multi_span_index(const value_type (&values)[Rank]) noexcept
|
constexpr multi_span_index(const value_type(&values)[Rank]) noexcept
|
||||||
{
|
{
|
||||||
GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
|
GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
|
||||||
GSL_SUPPRESS(bounds.3) // NO-FORMAT: attribute
|
GSL_SUPPRESS(bounds.3) // NO-FORMAT: attribute
|
||||||
@ -139,7 +139,7 @@ public:
|
|||||||
// Preconditions: component_idx < rank
|
// Preconditions: component_idx < rank
|
||||||
GSL_SUPPRESS(bounds.2) // NO-FORMAT: attribute
|
GSL_SUPPRESS(bounds.2) // NO-FORMAT: attribute
|
||||||
GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
|
GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
|
||||||
constexpr const_reference operator[](std::size_t component_idx) const
|
constexpr const_reference operator[](std::size_t component_idx) const
|
||||||
{
|
{
|
||||||
Expects(component_idx < Rank); // Component index must be less than rank
|
Expects(component_idx < Rank); // Component index must be less than rank
|
||||||
return elems[component_idx];
|
return elems[component_idx];
|
||||||
@ -152,10 +152,7 @@ public:
|
|||||||
return std::equal(elems, elems + rank, rhs.elems);
|
return std::equal(elems, elems + rank, rhs.elems);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr bool operator!=(const multi_span_index& rhs) const
|
constexpr bool operator!=(const multi_span_index& rhs) const { return !(*this == rhs); }
|
||||||
{
|
|
||||||
return !(*this == rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr multi_span_index operator+() const noexcept { return *this; }
|
constexpr multi_span_index operator+() const noexcept { return *this; }
|
||||||
|
|
||||||
@ -184,8 +181,7 @@ public:
|
|||||||
{
|
{
|
||||||
GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
|
GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
|
||||||
GSL_SUPPRESS(bounds.3) // NO-FORMAT: attribute
|
GSL_SUPPRESS(bounds.3) // NO-FORMAT: attribute
|
||||||
std::transform(elems, elems + rank, rhs.elems, elems,
|
std::transform(elems, elems + rank, rhs.elems, elems, std::plus<value_type>{});
|
||||||
std::plus<value_type>{});
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +236,7 @@ private:
|
|||||||
|
|
||||||
#if !defined(_MSC_VER) || _MSC_VER >= 1910
|
#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>>
|
template <typename T, typename = std::enable_if_t<std::is_integral<T>::value>>
|
||||||
constexpr operator T() const noexcept
|
constexpr operator T() const noexcept
|
||||||
@ -288,12 +284,10 @@ constexpr static_bounds_dynamic_range_t dynamic_range{};
|
|||||||
const std::ptrdiff_t dynamic_range = -1;
|
const std::ptrdiff_t dynamic_range = -1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct generalized_mapping_tag
|
struct [[deprecated]] generalized_mapping_tag
|
||||||
{
|
|
||||||
};
|
|
||||||
struct contiguous_mapping_tag : generalized_mapping_tag
|
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
struct[[deprecated]] contiguous_mapping_tag : generalized_mapping_tag{};
|
||||||
|
|
||||||
namespace details
|
namespace details
|
||||||
{
|
{
|
||||||
@ -305,8 +299,7 @@ namespace details
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <std::ptrdiff_t... Ranges>
|
template <std::ptrdiff_t... Ranges>
|
||||||
struct BoundsRanges
|
struct [[deprecated]] BoundsRanges {
|
||||||
{
|
|
||||||
using size_type = std::ptrdiff_t;
|
using size_type = std::ptrdiff_t;
|
||||||
static const size_type Depth = 0;
|
static const size_type Depth = 0;
|
||||||
static const size_type DynamicNum = 0;
|
static const size_type DynamicNum = 0;
|
||||||
@ -345,7 +338,7 @@ namespace details
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <std::ptrdiff_t... RestRanges>
|
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 Base = BoundsRanges<RestRanges...>;
|
||||||
using size_type = std::ptrdiff_t;
|
using size_type = std::ptrdiff_t;
|
||||||
@ -358,8 +351,9 @@ namespace details
|
|||||||
size_type m_bound;
|
size_type m_bound;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GSL_SUPPRESS(f.23) // NO-FORMAT: attribute // this pointer type is cannot be assigned nullptr - issue in not_null
|
GSL_SUPPRESS(
|
||||||
GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
|
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)
|
constexpr BoundsRanges(const std::ptrdiff_t* const arr)
|
||||||
: Base(arr + 1), m_bound(*arr * this->Base::totalSize())
|
: Base(arr + 1), m_bound(*arr * this->Base::totalSize())
|
||||||
{
|
{
|
||||||
@ -370,13 +364,13 @@ namespace details
|
|||||||
|
|
||||||
template <std::ptrdiff_t OtherRange, std::ptrdiff_t... RestOtherRanges>
|
template <std::ptrdiff_t OtherRange, std::ptrdiff_t... RestOtherRanges>
|
||||||
constexpr BoundsRanges(const BoundsRanges<OtherRange, RestOtherRanges...>& other,
|
constexpr BoundsRanges(const BoundsRanges<OtherRange, RestOtherRanges...>& other,
|
||||||
bool /* firstLevel */ = true)
|
bool /* firstLevel */ = true)
|
||||||
: Base(static_cast<const BoundsRanges<RestOtherRanges...>&>(other), false)
|
: Base(static_cast<const BoundsRanges<RestOtherRanges...>&>(other), false)
|
||||||
, m_bound(other.totalSize())
|
, m_bound(other.totalSize())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <typename T, std::size_t Dim = 0>
|
template <typename T, std::size_t Dim = 0>
|
||||||
constexpr void serialize(T& arr) const
|
constexpr void serialize(T & arr) const
|
||||||
{
|
{
|
||||||
arr[Dim] = elementNum();
|
arr[Dim] = elementNum();
|
||||||
this->Base::template serialize<T, Dim + 1>(arr);
|
this->Base::template serialize<T, Dim + 1>(arr);
|
||||||
@ -400,19 +394,19 @@ namespace details
|
|||||||
return cur < m_bound ? cur + last : -1;
|
return cur < m_bound ? cur + last : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
GSL_SUPPRESS(c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used
|
GSL_SUPPRESS(
|
||||||
constexpr size_type totalSize() const noexcept
|
c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used
|
||||||
{
|
constexpr size_type totalSize() const noexcept { return m_bound; }
|
||||||
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
|
constexpr size_type elementNum() const noexcept
|
||||||
{
|
{
|
||||||
return totalSize() / this->Base::totalSize();
|
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
|
constexpr size_type elementNum(std::size_t dim) const noexcept
|
||||||
{
|
{
|
||||||
if (dim > 0)
|
if (dim > 0)
|
||||||
@ -429,7 +423,7 @@ namespace details
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <std::ptrdiff_t CurRange, std::ptrdiff_t... RestRanges>
|
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 Base = BoundsRanges<RestRanges...>;
|
||||||
using size_type = std::ptrdiff_t;
|
using size_type = std::ptrdiff_t;
|
||||||
@ -444,7 +438,7 @@ namespace details
|
|||||||
|
|
||||||
template <std::ptrdiff_t OtherRange, std::ptrdiff_t... RestOtherRanges>
|
template <std::ptrdiff_t OtherRange, std::ptrdiff_t... RestOtherRanges>
|
||||||
constexpr BoundsRanges(const BoundsRanges<OtherRange, RestOtherRanges...>& other,
|
constexpr BoundsRanges(const BoundsRanges<OtherRange, RestOtherRanges...>& other,
|
||||||
bool firstLevel = true)
|
bool firstLevel = true)
|
||||||
: Base(static_cast<const BoundsRanges<RestOtherRanges...>&>(other), false)
|
: Base(static_cast<const BoundsRanges<RestOtherRanges...>&>(other), false)
|
||||||
{
|
{
|
||||||
GSL_SUPPRESS(type.4) // NO-FORMAT: attribute // TODO: false positive
|
GSL_SUPPRESS(type.4) // NO-FORMAT: attribute // TODO: false positive
|
||||||
@ -452,7 +446,7 @@ namespace details
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, std::size_t Dim = 0>
|
template <typename T, std::size_t Dim = 0>
|
||||||
constexpr void serialize(T& arr) const
|
constexpr void serialize(T & arr) const
|
||||||
{
|
{
|
||||||
arr[Dim] = elementNum();
|
arr[Dim] = elementNum();
|
||||||
this->Base::template serialize<T, Dim + 1>(arr);
|
this->Base::template serialize<T, Dim + 1>(arr);
|
||||||
@ -461,12 +455,11 @@ namespace details
|
|||||||
template <typename T, std::size_t Dim = 0>
|
template <typename T, std::size_t Dim = 0>
|
||||||
constexpr size_type linearize(const T& arr) const
|
constexpr size_type linearize(const T& arr) const
|
||||||
{
|
{
|
||||||
GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
|
GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
|
||||||
Expects(arr[Dim] >= 0 && arr[Dim] < CurrentRange); // Index is out of range
|
Expects(arr[Dim] >= 0 && arr[Dim] < CurrentRange); // Index is out of range
|
||||||
GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
|
GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
|
||||||
const ptrdiff_t d = arr[Dim];
|
const ptrdiff_t d = arr[Dim];
|
||||||
return this->Base::totalSize() * d +
|
return this->Base::totalSize() * d + this->Base::template linearize<T, Dim + 1>(arr);
|
||||||
this->Base::template linearize<T, Dim + 1>(arr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, std::size_t Dim = 0>
|
template <typename T, std::size_t Dim = 0>
|
||||||
@ -478,19 +471,19 @@ namespace details
|
|||||||
return this->Base::totalSize() * arr[Dim] + last;
|
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
|
constexpr size_type totalSize() const noexcept
|
||||||
{
|
{
|
||||||
return CurrentRange * this->Base::totalSize();
|
return CurrentRange * this->Base::totalSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
GSL_SUPPRESS(c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used
|
GSL_SUPPRESS(
|
||||||
constexpr size_type elementNum() const noexcept
|
c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used
|
||||||
{
|
constexpr size_type elementNum() const noexcept { return CurrentRange; }
|
||||||
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
|
constexpr size_type elementNum(std::size_t dim) const noexcept
|
||||||
{
|
{
|
||||||
if (dim > 0)
|
if (dim > 0)
|
||||||
@ -506,17 +499,14 @@ namespace details
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename SourceType, typename TargetType>
|
template <typename SourceType, typename TargetType>
|
||||||
struct BoundsRangeConvertible
|
struct[[deprecated]] BoundsRangeConvertible
|
||||||
: public std::integral_constant<bool, (SourceType::TotalSize >= TargetType::TotalSize ||
|
: public std::integral_constant<bool, (SourceType::TotalSize >= TargetType::TotalSize ||
|
||||||
TargetType::TotalSize == dynamic_range ||
|
TargetType::TotalSize == dynamic_range ||
|
||||||
SourceType::TotalSize == dynamic_range ||
|
SourceType::TotalSize == dynamic_range ||
|
||||||
TargetType::TotalSize == 0)>
|
TargetType::TotalSize == 0)>{};
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename TypeChain>
|
template <typename TypeChain>
|
||||||
struct TypeListIndexer
|
struct [[deprecated]] TypeListIndexer {
|
||||||
{
|
|
||||||
const TypeChain& obj_;
|
const TypeChain& obj_;
|
||||||
constexpr TypeListIndexer(const TypeChain& obj) : obj_(obj) {}
|
constexpr TypeListIndexer(const TypeChain& obj) : obj_(obj) {}
|
||||||
|
|
||||||
@ -529,13 +519,13 @@ namespace details
|
|||||||
template <std::size_t N, typename MyChain = TypeChain,
|
template <std::size_t N, typename MyChain = TypeChain,
|
||||||
typename MyBase = typename MyChain::Base>
|
typename MyBase = typename MyChain::Base>
|
||||||
constexpr auto getObj(std::false_type)
|
constexpr auto getObj(std::false_type)
|
||||||
-> decltype(TypeListIndexer<MyBase>(static_cast<const MyBase&>(obj_)).template get<N>())
|
->decltype(TypeListIndexer<MyBase>(static_cast<const MyBase&>(obj_)).template get<N>())
|
||||||
{
|
{
|
||||||
return TypeListIndexer<MyBase>(static_cast<const MyBase&>(obj_)).template get<N>();
|
return TypeListIndexer<MyBase>(static_cast<const MyBase&>(obj_)).template get<N>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <std::size_t N>
|
template <std::size_t N>
|
||||||
constexpr auto get() -> decltype(getObj<N - 1>(std::integral_constant<bool, N == 0>()))
|
constexpr auto get()->decltype(getObj<N - 1>(std::integral_constant<bool, N == 0>()))
|
||||||
{
|
{
|
||||||
return getObj<N - 1>(std::integral_constant<bool, N == 0>());
|
return getObj<N - 1>(std::integral_constant<bool, N == 0>());
|
||||||
}
|
}
|
||||||
@ -555,7 +545,7 @@ namespace details
|
|||||||
for (std::size_t i = 0; i < Rank - 1; ++i)
|
for (std::size_t i = 0; i < Rank - 1; ++i)
|
||||||
{
|
{
|
||||||
GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
|
GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
|
||||||
ret[i] = other[i + 1];
|
ret[i] = other[i + 1];
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -565,14 +555,13 @@ template <typename IndexType>
|
|||||||
class bounds_iterator;
|
class bounds_iterator;
|
||||||
|
|
||||||
template <std::ptrdiff_t... Ranges>
|
template <std::ptrdiff_t... Ranges>
|
||||||
class static_bounds
|
class [[deprecated]] static_bounds {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
static_bounds(const details::BoundsRanges<Ranges...>&) {}
|
static_bounds(const details::BoundsRanges<Ranges...>&) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <std::ptrdiff_t FirstRange, std::ptrdiff_t... RestRanges>
|
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...>;
|
using MyRanges = details::BoundsRanges<FirstRange, RestRanges...>;
|
||||||
|
|
||||||
@ -604,10 +593,10 @@ public:
|
|||||||
template <std::size_t Rank, typename SourceType, typename TargetType,
|
template <std::size_t Rank, typename SourceType, typename TargetType,
|
||||||
typename Ret = BoundsRangeConvertible2<typename SourceType::Base,
|
typename Ret = BoundsRangeConvertible2<typename SourceType::Base,
|
||||||
typename TargetType::Base, Rank>>
|
typename TargetType::Base, Rank>>
|
||||||
static auto helpBoundsRangeConvertible(SourceType, TargetType, std::true_type) -> Ret;
|
static auto helpBoundsRangeConvertible(SourceType, TargetType, std::true_type)->Ret;
|
||||||
|
|
||||||
template <std::size_t Rank, typename SourceType, typename TargetType>
|
template <std::size_t Rank, typename SourceType, typename TargetType>
|
||||||
static auto helpBoundsRangeConvertible(SourceType, TargetType, ...) -> std::false_type;
|
static auto helpBoundsRangeConvertible(SourceType, TargetType, ...)->std::false_type;
|
||||||
|
|
||||||
template <typename SourceType, typename TargetType, std::size_t Rank>
|
template <typename SourceType, typename TargetType, std::size_t Rank>
|
||||||
struct BoundsRangeConvertible2
|
struct BoundsRangeConvertible2
|
||||||
@ -724,10 +713,7 @@ public:
|
|||||||
return !(*this == rhs);
|
return !(*this == rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr const_iterator begin() const noexcept
|
constexpr const_iterator begin() const noexcept { return const_iterator(*this, index_type{}); }
|
||||||
{
|
|
||||||
return const_iterator(*this, index_type{});
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr const_iterator end() const noexcept
|
constexpr const_iterator end() const noexcept
|
||||||
{
|
{
|
||||||
@ -736,7 +722,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <std::size_t Rank>
|
template <std::size_t Rank>
|
||||||
class strided_bounds {
|
class [[deprecated]] strided_bounds {
|
||||||
template <std::size_t OtherRank>
|
template <std::size_t OtherRank>
|
||||||
friend class strided_bounds;
|
friend class strided_bounds;
|
||||||
|
|
||||||
@ -760,14 +746,13 @@ public:
|
|||||||
|
|
||||||
constexpr strided_bounds& operator=(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)
|
constexpr strided_bounds(const value_type(&values)[rank], index_type strides)
|
||||||
: m_extents(values), m_strides(std::move(strides))
|
: m_extents(values), m_strides(std::move(strides))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
constexpr strided_bounds(const index_type& extents, const index_type& strides) noexcept
|
constexpr strided_bounds(const index_type& extents, const index_type& strides) noexcept
|
||||||
: m_extents(extents), m_strides(strides)
|
: m_extents(extents), m_strides(strides)
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
constexpr index_type strides() const noexcept { return m_strides; }
|
constexpr index_type strides() const noexcept { return m_strides; }
|
||||||
|
|
||||||
@ -839,21 +824,14 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
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>
|
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>
|
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>
|
template <typename IndexType>
|
||||||
class bounds_iterator
|
class [[deprecated]] bounds_iterator {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
static const std::size_t rank = IndexType::rank;
|
static const std::size_t rank = IndexType::rank;
|
||||||
using iterator_category = std::random_access_iterator_tag;
|
using iterator_category = std::random_access_iterator_tag;
|
||||||
@ -974,7 +952,6 @@ public:
|
|||||||
return curr_ == rhs.curr_;
|
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 { return !(*this == rhs); }
|
||||||
|
|
||||||
constexpr bool operator<(const bounds_iterator& rhs) const noexcept
|
constexpr bool operator<(const bounds_iterator& rhs) const noexcept
|
||||||
@ -988,16 +965,15 @@ public:
|
|||||||
|
|
||||||
constexpr bool operator>=(const bounds_iterator& rhs) const noexcept { return !(rhs > *this); }
|
constexpr bool operator>=(const bounds_iterator& rhs) const noexcept { return !(rhs > *this); }
|
||||||
|
|
||||||
void swap(bounds_iterator& rhs) noexcept
|
void swap(bounds_iterator & rhs) noexcept
|
||||||
{
|
{
|
||||||
std::swap(boundary_, rhs.boundary_);
|
std::swap(boundary_, rhs.boundary_);
|
||||||
std::swap(curr_, rhs.curr_);
|
std::swap(curr_, rhs.curr_);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
|
GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
|
||||||
constexpr bool less(index_type& one, index_type& other) const noexcept
|
constexpr bool less(index_type & one, index_type & other) const noexcept
|
||||||
{
|
{
|
||||||
for (std::size_t i = 0; i < rank; ++i)
|
for (std::size_t i = 0; i < rank; ++i)
|
||||||
{
|
{
|
||||||
@ -1228,8 +1204,7 @@ namespace details
|
|||||||
} // namespace details
|
} // namespace details
|
||||||
|
|
||||||
template <typename ValueType, std::ptrdiff_t FirstDimension, std::ptrdiff_t... RestDimensions>
|
template <typename ValueType, std::ptrdiff_t FirstDimension, std::ptrdiff_t... RestDimensions>
|
||||||
class multi_span
|
class [[deprecated("This concept is not present in the C++ Core Guidelines")]] multi_span {
|
||||||
{
|
|
||||||
// TODO do we still need this?
|
// TODO do we still need this?
|
||||||
template <typename ValueType2, std::ptrdiff_t FirstDimension2,
|
template <typename ValueType2, std::ptrdiff_t FirstDimension2,
|
||||||
std::ptrdiff_t... RestDimensions2>
|
std::ptrdiff_t... RestDimensions2>
|
||||||
@ -1262,8 +1237,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
// default constructor - same as constructing from nullptr_t
|
// default constructor - same as constructing from nullptr_t
|
||||||
GSL_SUPPRESS(type.6) // NO-FORMAT: attribute // TODO: false positive
|
GSL_SUPPRESS(type.6) // NO-FORMAT: attribute // TODO: false positive
|
||||||
constexpr multi_span() noexcept
|
constexpr multi_span() noexcept : multi_span(nullptr, bounds_type{})
|
||||||
: multi_span(nullptr, bounds_type{})
|
|
||||||
{
|
{
|
||||||
static_assert(bounds_type::dynamic_rank != 0 ||
|
static_assert(bounds_type::dynamic_rank != 0 ||
|
||||||
(bounds_type::dynamic_rank == 0 && bounds_type::static_size == 0),
|
(bounds_type::dynamic_rank == 0 && bounds_type::static_size == 0),
|
||||||
@ -1273,8 +1247,7 @@ public:
|
|||||||
|
|
||||||
// construct from nullptr - get an empty multi_span
|
// construct from nullptr - get an empty multi_span
|
||||||
GSL_SUPPRESS(type.6) // NO-FORMAT: attribute // TODO: false positive
|
GSL_SUPPRESS(type.6) // NO-FORMAT: attribute // TODO: false positive
|
||||||
constexpr multi_span(std::nullptr_t) noexcept
|
constexpr multi_span(std::nullptr_t) noexcept : multi_span(nullptr, bounds_type{})
|
||||||
: multi_span(nullptr, bounds_type{})
|
|
||||||
{
|
{
|
||||||
static_assert(bounds_type::dynamic_rank != 0 ||
|
static_assert(bounds_type::dynamic_rank != 0 ||
|
||||||
(bounds_type::dynamic_rank == 0 && bounds_type::static_size == 0),
|
(bounds_type::dynamic_rank == 0 && bounds_type::static_size == 0),
|
||||||
@ -1298,8 +1271,7 @@ public:
|
|||||||
// construct from a single element
|
// construct from a single element
|
||||||
|
|
||||||
GSL_SUPPRESS(type.6) // NO-FORMAT: attribute // TODO: false positive
|
GSL_SUPPRESS(type.6) // NO-FORMAT: attribute // TODO: false positive
|
||||||
constexpr multi_span(reference data) noexcept
|
constexpr multi_span(reference data) noexcept : multi_span(&data, bounds_type{1})
|
||||||
: multi_span(&data, bounds_type{1})
|
|
||||||
{
|
{
|
||||||
static_assert(bounds_type::dynamic_rank > 0 || bounds_type::static_size == 0 ||
|
static_assert(bounds_type::dynamic_rank > 0 || bounds_type::static_size == 0 ||
|
||||||
bounds_type::static_size == 1,
|
bounds_type::static_size == 1,
|
||||||
@ -1308,17 +1280,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// prevent constructing from temporaries for single-elements
|
// prevent constructing from temporaries for single-elements
|
||||||
constexpr multi_span(value_type&&) = delete;
|
constexpr multi_span(value_type &&) = delete;
|
||||||
|
|
||||||
// construct from pointer + length
|
// construct from pointer + length
|
||||||
GSL_SUPPRESS(type.6) // NO-FORMAT: attribute // TODO: false positive
|
GSL_SUPPRESS(type.6) // NO-FORMAT: attribute // TODO: false positive
|
||||||
constexpr multi_span(pointer ptr, size_type size)
|
constexpr multi_span(pointer ptr, size_type size) : multi_span(ptr, bounds_type{size}) {}
|
||||||
: multi_span(ptr, bounds_type{size})
|
|
||||||
{}
|
|
||||||
|
|
||||||
// construct from pointer + length - multidimensional
|
// construct from pointer + length - multidimensional
|
||||||
constexpr multi_span(pointer data, bounds_type bounds)
|
constexpr multi_span(pointer data, bounds_type bounds) : data_(data), bounds_(std::move(bounds))
|
||||||
: data_(data), bounds_(std::move(bounds))
|
|
||||||
{
|
{
|
||||||
Expects((bounds_.size() > 0 && data != nullptr) || bounds_.size() == 0);
|
Expects((bounds_.size() > 0 && data != nullptr) || bounds_.size() == 0);
|
||||||
}
|
}
|
||||||
@ -1336,7 +1305,7 @@ public:
|
|||||||
|
|
||||||
// construct from n-dimensions static array
|
// construct from n-dimensions static array
|
||||||
template <typename T, std::size_t N, typename Helper = details::SpanArrayTraits<T, N>>
|
template <typename T, std::size_t N, typename Helper = details::SpanArrayTraits<T, N>>
|
||||||
constexpr multi_span(T (&arr)[N])
|
constexpr multi_span(T(&arr)[N])
|
||||||
: multi_span(reinterpret_cast<pointer>(arr), bounds_type{typename Helper::bounds_type{}})
|
: multi_span(reinterpret_cast<pointer>(arr), bounds_type{typename Helper::bounds_type{}})
|
||||||
{
|
{
|
||||||
static_assert(std::is_convertible<typename Helper::value_type(*)[], value_type(*)[]>::value,
|
static_assert(std::is_convertible<typename Helper::value_type(*)[], value_type(*)[]>::value,
|
||||||
@ -1357,7 +1326,7 @@ public:
|
|||||||
|
|
||||||
// construct from std::array
|
// construct from std::array
|
||||||
template <typename T, std::size_t N>
|
template <typename T, std::size_t N>
|
||||||
constexpr multi_span(std::array<T, N>& arr)
|
constexpr multi_span(std::array<T, N> & arr)
|
||||||
: multi_span(arr.data(), bounds_type{static_bounds<N>{}})
|
: multi_span(arr.data(), bounds_type{static_bounds<N>{}})
|
||||||
{
|
{
|
||||||
static_assert(
|
static_assert(
|
||||||
@ -1381,7 +1350,7 @@ public:
|
|||||||
|
|
||||||
// prevent constructing from temporary std::array
|
// prevent constructing from temporary std::array
|
||||||
template <typename T, std::size_t N>
|
template <typename T, std::size_t N>
|
||||||
constexpr multi_span(std::array<T, N>&& arr) = delete;
|
constexpr multi_span(std::array<T, N> && arr) = delete;
|
||||||
|
|
||||||
// construct from containers
|
// construct from containers
|
||||||
// future: could use contiguous_iterator_traits to identify only contiguous containers
|
// future: could use contiguous_iterator_traits to identify only contiguous containers
|
||||||
@ -1389,11 +1358,11 @@ public:
|
|||||||
template <typename Cont, typename DataType = typename Cont::value_type,
|
template <typename Cont, typename DataType = typename Cont::value_type,
|
||||||
typename = std::enable_if_t<
|
typename = std::enable_if_t<
|
||||||
!details::is_multi_span<Cont>::value &&
|
!details::is_multi_span<Cont>::value &&
|
||||||
std::is_convertible<DataType (*)[], value_type (*)[]>::value &&
|
std::is_convertible<DataType(*)[], value_type(*)[]>::value &&
|
||||||
std::is_same<std::decay_t<decltype(std::declval<Cont>().size(),
|
std::is_same<std::decay_t<decltype(std::declval<Cont>().size(),
|
||||||
*std::declval<Cont>().data())>,
|
*std::declval<Cont>().data())>,
|
||||||
DataType>::value>>
|
DataType>::value>>
|
||||||
constexpr multi_span(Cont& cont)
|
constexpr multi_span(Cont & cont)
|
||||||
: multi_span(static_cast<pointer>(cont.data()),
|
: multi_span(static_cast<pointer>(cont.data()),
|
||||||
details::newBoundsHelper<bounds_type>(narrow_cast<size_type>(cont.size())))
|
details::newBoundsHelper<bounds_type>(narrow_cast<size_type>(cont.size())))
|
||||||
{}
|
{}
|
||||||
@ -1402,11 +1371,11 @@ public:
|
|||||||
template <typename Cont, typename DataType = typename Cont::value_type,
|
template <typename Cont, typename DataType = typename Cont::value_type,
|
||||||
typename = std::enable_if_t<
|
typename = std::enable_if_t<
|
||||||
!details::is_multi_span<Cont>::value &&
|
!details::is_multi_span<Cont>::value &&
|
||||||
std::is_convertible<DataType (*)[], value_type (*)[]>::value &&
|
std::is_convertible<DataType(*)[], value_type(*)[]>::value &&
|
||||||
std::is_same<std::decay_t<decltype(std::declval<Cont>().size(),
|
std::is_same<std::decay_t<decltype(std::declval<Cont>().size(),
|
||||||
*std::declval<Cont>().data())>,
|
*std::declval<Cont>().data())>,
|
||||||
DataType>::value>>
|
DataType>::value>>
|
||||||
explicit constexpr multi_span(Cont&& cont) = delete;
|
explicit constexpr multi_span(Cont && cont) = delete;
|
||||||
|
|
||||||
// construct from a convertible multi_span
|
// construct from a convertible multi_span
|
||||||
template <typename OtherValueType, std::ptrdiff_t... OtherDimensions,
|
template <typename OtherValueType, std::ptrdiff_t... OtherDimensions,
|
||||||
@ -1419,7 +1388,7 @@ public:
|
|||||||
|
|
||||||
// trivial copy and move
|
// trivial copy and move
|
||||||
constexpr multi_span(const multi_span&) = default;
|
constexpr multi_span(const multi_span&) = default;
|
||||||
constexpr multi_span(multi_span&&) = default;
|
constexpr multi_span(multi_span &&) = default;
|
||||||
|
|
||||||
// trivial assignment
|
// trivial assignment
|
||||||
constexpr multi_span& operator=(const multi_span&) = default;
|
constexpr multi_span& operator=(const multi_span&) = default;
|
||||||
@ -1493,8 +1462,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// section - creates a non-contiguous, strided multi_span from a contiguous one
|
// section - creates a non-contiguous, strided multi_span from a contiguous one
|
||||||
constexpr strided_span<ValueType, Rank> section(index_type origin,
|
constexpr strided_span<ValueType, Rank> section(index_type origin, index_type extents) const
|
||||||
index_type extents) const
|
|
||||||
{
|
{
|
||||||
const size_type size = this->bounds().total_size() - this->bounds().linearize(origin);
|
const size_type size = this->bounds().total_size() - this->bounds().linearize(origin);
|
||||||
return {&this->operator[](origin), size,
|
return {&this->operator[](origin), size,
|
||||||
@ -1636,8 +1604,8 @@ public:
|
|||||||
template <typename OtherValueType, std::ptrdiff_t... OtherDimensions,
|
template <typename OtherValueType, std::ptrdiff_t... OtherDimensions,
|
||||||
typename = std::enable_if_t<std::is_same<std::remove_cv_t<value_type>,
|
typename = std::enable_if_t<std::is_same<std::remove_cv_t<value_type>,
|
||||||
std::remove_cv_t<OtherValueType>>::value>>
|
std::remove_cv_t<OtherValueType>>::value>>
|
||||||
constexpr bool operator>(const multi_span<OtherValueType, OtherDimensions...>& other) const
|
constexpr bool operator>(const multi_span<OtherValueType, OtherDimensions...>& other)
|
||||||
noexcept
|
const noexcept
|
||||||
{
|
{
|
||||||
return (other < *this);
|
return (other < *this);
|
||||||
}
|
}
|
||||||
@ -1659,7 +1627,7 @@ public:
|
|||||||
// DimCount and Enabled here are workarounds for a bug in MSVC 2015
|
// DimCount and Enabled here are workarounds for a bug in MSVC 2015
|
||||||
template <typename SpanType, typename... Dimensions2, std::size_t DimCount = sizeof...(Dimensions2),
|
template <typename SpanType, typename... Dimensions2, std::size_t DimCount = sizeof...(Dimensions2),
|
||||||
bool Enabled = (DimCount > 0), typename = std::enable_if_t<Enabled>>
|
bool Enabled = (DimCount > 0), typename = std::enable_if_t<Enabled>>
|
||||||
constexpr auto as_multi_span(SpanType s, Dimensions2... dims)
|
[[deprecated]] constexpr auto as_multi_span(SpanType s, Dimensions2... dims)
|
||||||
-> multi_span<typename SpanType::value_type, Dimensions2::value...>
|
-> multi_span<typename SpanType::value_type, Dimensions2::value...>
|
||||||
{
|
{
|
||||||
static_assert(details::is_multi_span<SpanType>::value,
|
static_assert(details::is_multi_span<SpanType>::value,
|
||||||
@ -1673,7 +1641,8 @@ constexpr auto as_multi_span(SpanType s, Dimensions2... dims)
|
|||||||
|
|
||||||
// convert a multi_span<T> to a multi_span<const byte>
|
// convert a multi_span<T> to a multi_span<const byte>
|
||||||
template <typename U, std::ptrdiff_t... Dimensions>
|
template <typename U, std::ptrdiff_t... Dimensions>
|
||||||
multi_span<const byte, dynamic_range> as_bytes(multi_span<U, Dimensions...> s) noexcept
|
[[deprecated]] multi_span<const byte, dynamic_range>
|
||||||
|
as_bytes(multi_span<U, Dimensions...> s) noexcept
|
||||||
{
|
{
|
||||||
static_assert(std::is_trivial<std::decay_t<U>>::value,
|
static_assert(std::is_trivial<std::decay_t<U>>::value,
|
||||||
"The value_type of multi_span must be a trivial type.");
|
"The value_type of multi_span must be a trivial type.");
|
||||||
@ -1685,7 +1654,7 @@ multi_span<const byte, dynamic_range> as_bytes(multi_span<U, Dimensions...> s) n
|
|||||||
// on all implementations. It should be considered an experimental extension
|
// on all implementations. It should be considered an experimental extension
|
||||||
// to the standard GSL interface.
|
// to the standard GSL interface.
|
||||||
template <typename U, std::ptrdiff_t... Dimensions>
|
template <typename U, std::ptrdiff_t... Dimensions>
|
||||||
multi_span<byte> as_writeable_bytes(multi_span<U, Dimensions...> s) noexcept
|
[[deprecated]] multi_span<byte> as_writeable_bytes(multi_span<U, Dimensions...> s) noexcept
|
||||||
{
|
{
|
||||||
static_assert(std::is_trivial<std::decay_t<U>>::value,
|
static_assert(std::is_trivial<std::decay_t<U>>::value,
|
||||||
"The value_type of multi_span must be a trivial type.");
|
"The value_type of multi_span must be a trivial type.");
|
||||||
@ -1697,7 +1666,7 @@ multi_span<byte> as_writeable_bytes(multi_span<U, Dimensions...> s) noexcept
|
|||||||
// on all implementations. It should be considered an experimental extension
|
// on all implementations. It should be considered an experimental extension
|
||||||
// to the standard GSL interface.
|
// to the standard GSL interface.
|
||||||
template <typename U, std::ptrdiff_t... Dimensions>
|
template <typename U, std::ptrdiff_t... Dimensions>
|
||||||
constexpr auto as_multi_span(multi_span<const byte, Dimensions...> s) -> multi_span<
|
[[deprecated]] constexpr auto as_multi_span(multi_span<const byte, Dimensions...> s) -> multi_span<
|
||||||
const U, static_cast<std::ptrdiff_t>(
|
const U, static_cast<std::ptrdiff_t>(
|
||||||
multi_span<const byte, Dimensions...>::bounds_type::static_size != dynamic_range
|
multi_span<const byte, Dimensions...>::bounds_type::static_size != dynamic_range
|
||||||
? (static_cast<std::size_t>(
|
? (static_cast<std::size_t>(
|
||||||
@ -1723,7 +1692,7 @@ constexpr auto as_multi_span(multi_span<const byte, Dimensions...> s) -> multi_s
|
|||||||
// on all implementations. It should be considered an experimental extension
|
// on all implementations. It should be considered an experimental extension
|
||||||
// to the standard GSL interface.
|
// to the standard GSL interface.
|
||||||
template <typename U, std::ptrdiff_t... Dimensions>
|
template <typename U, std::ptrdiff_t... Dimensions>
|
||||||
constexpr auto as_multi_span(multi_span<byte, Dimensions...> s)
|
[[deprecated]] constexpr auto as_multi_span(multi_span<byte, Dimensions...> s)
|
||||||
-> multi_span<U, narrow_cast<std::ptrdiff_t>(
|
-> multi_span<U, narrow_cast<std::ptrdiff_t>(
|
||||||
multi_span<byte, Dimensions...>::bounds_type::static_size != dynamic_range
|
multi_span<byte, Dimensions...>::bounds_type::static_size != dynamic_range
|
||||||
? static_cast<std::size_t>(
|
? static_cast<std::size_t>(
|
||||||
@ -1743,7 +1712,7 @@ constexpr auto as_multi_span(multi_span<byte, Dimensions...> s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, std::ptrdiff_t... Dimensions>
|
template <typename T, std::ptrdiff_t... Dimensions>
|
||||||
constexpr auto as_multi_span(T* const& ptr, dim_t<Dimensions>... args)
|
[[deprecated]] constexpr auto as_multi_span(T* const& ptr, dim_t<Dimensions>... args)
|
||||||
-> multi_span<std::remove_all_extents_t<T>, Dimensions...>
|
-> multi_span<std::remove_all_extents_t<T>, Dimensions...>
|
||||||
{
|
{
|
||||||
return {reinterpret_cast<std::remove_all_extents_t<T>*>(ptr),
|
return {reinterpret_cast<std::remove_all_extents_t<T>*>(ptr),
|
||||||
@ -1752,41 +1721,42 @@ constexpr auto as_multi_span(T* const& ptr, dim_t<Dimensions>... args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr auto as_multi_span(T* arr, std::ptrdiff_t len) ->
|
[[deprecated]] constexpr auto as_multi_span(T* arr, std::ptrdiff_t len) ->
|
||||||
typename details::SpanArrayTraits<T, dynamic_range>::type
|
typename details::SpanArrayTraits<T, dynamic_range>::type
|
||||||
{
|
{
|
||||||
return {reinterpret_cast<std::remove_all_extents_t<T>*>(arr), len};
|
return {reinterpret_cast<std::remove_all_extents_t<T>*>(arr), len};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, std::size_t N>
|
template <typename T, std::size_t N>
|
||||||
constexpr auto as_multi_span(T (&arr)[N]) -> typename details::SpanArrayTraits<T, N>::type
|
[[deprecated]] constexpr auto as_multi_span(T (&arr)[N]) ->
|
||||||
|
typename details::SpanArrayTraits<T, N>::type
|
||||||
{
|
{
|
||||||
return {arr};
|
return {arr};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, std::size_t N>
|
template <typename T, std::size_t N>
|
||||||
constexpr multi_span<const T, N> as_multi_span(const std::array<T, N>& arr)
|
[[deprecated]] constexpr multi_span<const T, N> as_multi_span(const std::array<T, N>& arr)
|
||||||
{
|
{
|
||||||
return {arr};
|
return {arr};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, std::size_t N>
|
template <typename T, std::size_t N>
|
||||||
constexpr multi_span<const T, N> as_multi_span(const std::array<T, N>&&) = delete;
|
[[deprecated]] constexpr multi_span<const T, N> as_multi_span(const std::array<T, N>&&) = delete;
|
||||||
|
|
||||||
template <typename T, std::size_t N>
|
template <typename T, std::size_t N>
|
||||||
constexpr multi_span<T, N> as_multi_span(std::array<T, N>& arr)
|
[[deprecated]] constexpr multi_span<T, N> as_multi_span(std::array<T, N>& arr)
|
||||||
{
|
{
|
||||||
return {arr};
|
return {arr};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr multi_span<T, dynamic_range> as_multi_span(T* begin, T* end)
|
[[deprecated]] constexpr multi_span<T, dynamic_range> as_multi_span(T* begin, T* end)
|
||||||
{
|
{
|
||||||
return {begin, end};
|
return {begin, end};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Cont>
|
template <typename Cont>
|
||||||
constexpr auto as_multi_span(Cont& arr) -> std::enable_if_t<
|
[[deprecated]] constexpr auto as_multi_span(Cont& arr) -> std::enable_if_t<
|
||||||
!details::is_multi_span<std::decay_t<Cont>>::value,
|
!details::is_multi_span<std::decay_t<Cont>>::value,
|
||||||
multi_span<std::remove_reference_t<decltype(arr.size(), *arr.data())>, dynamic_range>>
|
multi_span<std::remove_reference_t<decltype(arr.size(), *arr.data())>, dynamic_range>>
|
||||||
{
|
{
|
||||||
@ -1795,14 +1765,14 @@ constexpr auto as_multi_span(Cont& arr) -> std::enable_if_t<
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Cont>
|
template <typename Cont>
|
||||||
constexpr auto as_multi_span(Cont&& arr) -> std::enable_if_t<
|
[[deprecated]] constexpr auto as_multi_span(Cont&& arr) -> std::enable_if_t<
|
||||||
!details::is_multi_span<std::decay_t<Cont>>::value,
|
!details::is_multi_span<std::decay_t<Cont>>::value,
|
||||||
multi_span<std::remove_reference_t<decltype(arr.size(), *arr.data())>, dynamic_range>> = delete;
|
multi_span<std::remove_reference_t<decltype(arr.size(), *arr.data())>, dynamic_range>> = delete;
|
||||||
|
|
||||||
// from basic_string which doesn't have nonconst .data() member like other contiguous containers
|
// from basic_string which doesn't have nonconst .data() member like other contiguous containers
|
||||||
template <typename CharT, typename Traits, typename Allocator>
|
template <typename CharT, typename Traits, typename Allocator>
|
||||||
GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
|
GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
|
||||||
constexpr auto as_multi_span(std::basic_string<CharT, Traits, Allocator>& str)
|
[[deprecated]] constexpr auto as_multi_span(std::basic_string<CharT, Traits, Allocator>& str)
|
||||||
-> multi_span<CharT, dynamic_range>
|
-> multi_span<CharT, dynamic_range>
|
||||||
{
|
{
|
||||||
Expects(str.size() < PTRDIFF_MAX);
|
Expects(str.size() < PTRDIFF_MAX);
|
||||||
@ -2055,8 +2025,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <class Span>
|
template <class Span>
|
||||||
class contiguous_span_iterator
|
class [[deprecated]] contiguous_span_iterator {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
using iterator_category = std::random_access_iterator_tag;
|
using iterator_category = std::random_access_iterator_tag;
|
||||||
using value_type = typename Span::value_type;
|
using value_type = typename Span::value_type;
|
||||||
@ -2072,7 +2041,8 @@ private:
|
|||||||
const Span* m_validator;
|
const Span* m_validator;
|
||||||
|
|
||||||
GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
|
GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute
|
||||||
void validateThis() const {
|
void validateThis() const
|
||||||
|
{
|
||||||
// iterator is out of range of the array
|
// iterator is out of range of the array
|
||||||
Expects(data_ >= m_validator->data_ && data_ < m_validator->data_ + m_validator->size());
|
Expects(data_ >= m_validator->data_ && data_ < m_validator->data_ + m_validator->size());
|
||||||
}
|
}
|
||||||
@ -2161,7 +2131,7 @@ public:
|
|||||||
bool operator>(const contiguous_span_iterator& rhs) const { return rhs < *this; }
|
bool operator>(const contiguous_span_iterator& rhs) const { return rhs < *this; }
|
||||||
bool operator>=(const contiguous_span_iterator& rhs) const { return !(rhs > *this); }
|
bool operator>=(const contiguous_span_iterator& rhs) const { return !(rhs > *this); }
|
||||||
|
|
||||||
void swap(contiguous_span_iterator& rhs) noexcept
|
void swap(contiguous_span_iterator & rhs) noexcept
|
||||||
{
|
{
|
||||||
std::swap(data_, rhs.data_);
|
std::swap(data_, rhs.data_);
|
||||||
std::swap(m_validator, rhs.m_validator);
|
std::swap(m_validator, rhs.m_validator);
|
||||||
@ -2176,7 +2146,8 @@ contiguous_span_iterator<Span> operator+(typename contiguous_span_iterator<Span>
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Span>
|
template <typename Span>
|
||||||
class general_span_iterator {
|
class [[deprecated(
|
||||||
|
"This concept is not present in the C++ Core Guidelines")]] general_span_iterator {
|
||||||
public:
|
public:
|
||||||
using iterator_category = std::random_access_iterator_tag;
|
using iterator_category = std::random_access_iterator_tag;
|
||||||
using value_type = typename Span::value_type;
|
using value_type = typename Span::value_type;
|
||||||
@ -2259,7 +2230,7 @@ public:
|
|||||||
bool operator<=(const general_span_iterator& rhs) const { return !(rhs < *this); }
|
bool operator<=(const general_span_iterator& rhs) const { return !(rhs < *this); }
|
||||||
bool operator>(const general_span_iterator& rhs) const { return rhs < *this; }
|
bool operator>(const general_span_iterator& rhs) const { return rhs < *this; }
|
||||||
bool operator>=(const general_span_iterator& rhs) const { return !(rhs > *this); }
|
bool operator>=(const general_span_iterator& rhs) const { return !(rhs > *this); }
|
||||||
void swap(general_span_iterator& rhs) noexcept
|
void swap(general_span_iterator & rhs) noexcept
|
||||||
{
|
{
|
||||||
std::swap(m_itr, rhs.m_itr);
|
std::swap(m_itr, rhs.m_itr);
|
||||||
std::swap(m_container, rhs.m_container);
|
std::swap(m_container, rhs.m_container);
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
// blanket turn off warnings from CppCoreCheck from catch
|
// blanket turn off warnings from CppCoreCheck from catch
|
||||||
// so people aren't annoyed by them when running the tool.
|
// so people aren't annoyed by them when running the tool.
|
||||||
#pragma warning(disable : 26440 26426) // from catch
|
#pragma warning(disable : 26440 26426 4996) // from catch deprecated
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <catch/catch.hpp> // for AssertionHandler, StringRef, TEST_CASE
|
#include <catch/catch.hpp> // for AssertionHandler, StringRef, TEST_CASE
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
// blanket turn off warnings from CppCoreCheck from catch
|
// blanket turn off warnings from CppCoreCheck from catch
|
||||||
// so people aren't annoyed by them when running the tool.
|
// so people aren't annoyed by them when running the tool.
|
||||||
#pragma warning(disable : 26440 26426) // from catch
|
#pragma warning(disable : 26440 26426 4996) // from catch deprecated
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
// blanket turn off warnings from CppCoreCheck from catch
|
// blanket turn off warnings from CppCoreCheck from catch
|
||||||
// so people aren't annoyed by them when running the tool.
|
// so people aren't annoyed by them when running the tool.
|
||||||
#pragma warning(disable : 26440 26426) // from catch
|
#pragma warning(disable : 26440 26426 4996) // from catch deprecated
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user