Skip to content

Commit

Permalink
Merge pull request #4737 from mclow3/span.175008384
Browse files Browse the repository at this point in the history
Remove some extra 'noexcept's in span {DRQS 175008384}
  • Loading branch information
cppguru authored and GitHub Enterprise committed May 13, 2024
2 parents 19dd3d6 + ca59324 commit abdd771
Show file tree
Hide file tree
Showing 2 changed files with 315 additions and 81 deletions.
75 changes: 34 additions & 41 deletions groups/bsl/bslstl/bslstl_span.h
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ class span {
// Destroy this object.

// ACCESSORS
BSLS_KEYWORD_CONSTEXPR_CPP14 reference back() const BSLS_KEYWORD_NOEXCEPT
BSLS_KEYWORD_CONSTEXPR_CPP14 reference back() const
// Return a reference to the last element of this span. The behavior
// is undefined if this span is empty.
{
Expand All @@ -427,19 +427,19 @@ class span {

template <size_t COUNT>
BSLS_KEYWORD_CONSTEXPR_CPP14
span<element_type, COUNT> first() const BSLS_KEYWORD_NOEXCEPT;
span<element_type, COUNT> first() const;
// Return a statically-sized span consisting of the first 'COUNT'
// elements of this span. The behavior is undefined unless
// 'COUNT <= size()'.

BSLS_KEYWORD_CONSTEXPR_CPP14
span<element_type, dynamic_extent>
first(size_type count) const BSLS_KEYWORD_NOEXCEPT;
first(size_type count) const;
// Return a dynamically-sized span consisting of the first (specified)
// 'count' elements of this span. The behavior is undefined unless
// 'count <= size()'.

BSLS_KEYWORD_CONSTEXPR_CPP14 reference front() const BSLS_KEYWORD_NOEXCEPT
BSLS_KEYWORD_CONSTEXPR_CPP14 reference front() const
// Return a reference to the first element of this span. The behavior
// is undefined if this span is empty.
{
Expand All @@ -450,14 +450,14 @@ class span {

template <size_t COUNT>
BSLS_KEYWORD_CONSTEXPR_CPP14
span<element_type, COUNT> last() const BSLS_KEYWORD_NOEXCEPT;
span<element_type, COUNT> last() const;
// Return a statically-sized span consisting of the last 'COUNT'
// elements of this span. The behavior is undefined unless
// 'COUNT <= size()'.

BSLS_KEYWORD_CONSTEXPR_CPP14
span<element_type, dynamic_extent>
last(size_type count) const BSLS_KEYWORD_NOEXCEPT;
last(size_type count) const;
// Return a dynamically-sized span consisting of the last (specified)
// 'count' elements of this span. The behavior is undefined unless
// 'count <= size()'.
Expand All @@ -480,7 +480,7 @@ class span {
#endif
BSLS_KEYWORD_CONSTEXPR_CPP14
typename Span_Utility::SubspanReturnType<TYPE, EXTENT, COUNT, OFFSET>::type
subspan() const BSLS_KEYWORD_NOEXCEPT
subspan() const
// If the template parameter 'COUNT' is 'dynamic_extent', return a
// dynamically-sized span consisting consisting of the elements of this
// span in the half-open range '[OFFSET, EXTENT)'. Otherwise, return a
Expand All @@ -501,8 +501,7 @@ class span {

BSLS_KEYWORD_CONSTEXPR_CPP14
span<element_type, dynamic_extent>
subspan(size_type offset, size_type count = dynamic_extent)
const BSLS_KEYWORD_NOEXCEPT;
subspan(size_type offset, size_type count = dynamic_extent) const;
// Return a dynamically-sized span starting at the specified 'offset'.
// If the optionally specified 'count' is 'dynamic_extent', the span
// will consist of the half-open range '[offset, size () - offset)' and
Expand All @@ -511,7 +510,7 @@ class span {
// behavior is undefined if 'offset + count > size()'.

BSLS_KEYWORD_CONSTEXPR_CPP14
reference operator[](size_type index) const BSLS_KEYWORD_NOEXCEPT
reference operator[](size_type index) const
// Return a reference to the element at the specified 'index'. The
// behavior is undefined unless 'index < size()'.
{
Expand Down Expand Up @@ -736,7 +735,7 @@ class span<TYPE, dynamic_extent> {
// Destroy this object.

// ACCESSORS
BSLS_KEYWORD_CONSTEXPR_CPP14 reference back() const BSLS_KEYWORD_NOEXCEPT;
BSLS_KEYWORD_CONSTEXPR_CPP14 reference back() const;
// Return a reference to the last element of this span. The behavior
// is undefined if this span is empty.

Expand All @@ -748,32 +747,32 @@ class span<TYPE, dynamic_extent> {

template <size_t COUNT>
BSLS_KEYWORD_CONSTEXPR_CPP14
span<element_type, COUNT> first() const BSLS_KEYWORD_NOEXCEPT;
span<element_type, COUNT> first() const;
// Return a statically-sized span consisting of the first 'COUNT'
// elements of this span. The behavior is undefined unless
// 'COUNT <= size()'.

BSLS_KEYWORD_CONSTEXPR_CPP14
span<element_type, dynamic_extent>
first(size_type count) const BSLS_KEYWORD_NOEXCEPT;
first(size_type count) const;
// Return a dynamically-sized span consisting of the first (specified)
// 'count' elements of this span. The behavior is undefined unless
// 'count <= size()'.

BSLS_KEYWORD_CONSTEXPR_CPP14 reference front() const BSLS_KEYWORD_NOEXCEPT;
BSLS_KEYWORD_CONSTEXPR_CPP14 reference front() const;
// Return a reference to the first element of this span. The behavior
// is undefined if this span is empty.

template <size_t COUNT>
BSLS_KEYWORD_CONSTEXPR_CPP14
span<element_type, COUNT> last() const BSLS_KEYWORD_NOEXCEPT;
span<element_type, COUNT> last() const;
// Return a statically-sized span consisting of the last 'COUNT'
// elements of this span. The behavior is undefined unless
// 'COUNT <= size()'.

BSLS_KEYWORD_CONSTEXPR_CPP14
span<element_type, dynamic_extent>
last(size_type count) const BSLS_KEYWORD_NOEXCEPT;
last(size_type count) const;
// Return a dynamically-sized span consisting of the last (specified)
// 'count' elements of this span. The behavior is undefined unless
// 'count <= size()'.
Expand All @@ -791,14 +790,13 @@ class span<TYPE, dynamic_extent> {
size_t COUNT>
#endif
BSLS_KEYWORD_CONSTEXPR_CPP14
span<element_type, COUNT> subspan() const BSLS_KEYWORD_NOEXCEPT;
span<element_type, COUNT> subspan() const;
// Return a dynamically-sized span consisting of the 'COUNT' elements
// of this span starting at 'OFFSET'. The behavior is undefined unless
// 'COUNT + OFFSET <= size()'.

BSLS_KEYWORD_CONSTEXPR_CPP14 span<element_type, dynamic_extent>
subspan(size_type offset, size_type count = dynamic_extent)
const BSLS_KEYWORD_NOEXCEPT;
subspan(size_type offset, size_type count = dynamic_extent) const;
// Return a dynamically-sized span starting at the specified 'offset'.
// If the optionally specified 'count' is 'dynamic_extent', the span
// will consist of the half-open range '[offset, size () - offset)' and
Expand All @@ -807,7 +805,7 @@ class span<TYPE, dynamic_extent> {
// behavior is undefined unless 'offset + count <= size()'.

BSLS_KEYWORD_CONSTEXPR_CPP14
reference operator[](size_type index) const BSLS_KEYWORD_NOEXCEPT;
reference operator[](size_type index) const;
// Return a reference to the element at the specified 'index'. The
// behavior is undefined unless 'index < size()'.

Expand Down Expand Up @@ -1084,7 +1082,7 @@ template <class TYPE, size_t EXTENT>
template <size_t COUNT>
BSLS_KEYWORD_CONSTEXPR_CPP14 inline
bsl::span<TYPE, COUNT>
bsl::span<TYPE, EXTENT>::first() const BSLS_KEYWORD_NOEXCEPT
bsl::span<TYPE, EXTENT>::first() const
{
typedef bsl::span<TYPE, COUNT> ReturnType;
BSLMF_ASSERT(COUNT <= EXTENT);
Expand All @@ -1094,7 +1092,7 @@ bsl::span<TYPE, EXTENT>::first() const BSLS_KEYWORD_NOEXCEPT
template <class TYPE, size_t EXTENT>
BSLS_KEYWORD_CONSTEXPR_CPP14 inline
bsl::span<TYPE, bsl::dynamic_extent>
bsl::span<TYPE, EXTENT>::first(size_type count) const BSLS_KEYWORD_NOEXCEPT
bsl::span<TYPE, EXTENT>::first(size_type count) const
{
typedef bsl::span<TYPE, bsl::dynamic_extent> ReturnType;
BSLS_ASSERT(count <= size());
Expand All @@ -1105,7 +1103,7 @@ template <class TYPE, size_t EXTENT>
template <size_t COUNT>
BSLS_KEYWORD_CONSTEXPR_CPP14 inline
bsl::span<TYPE, COUNT>
bsl::span<TYPE, EXTENT>::last() const BSLS_KEYWORD_NOEXCEPT
bsl::span<TYPE, EXTENT>::last() const
{
typedef bsl::span<TYPE, COUNT> ReturnType;
BSLMF_ASSERT(COUNT <= EXTENT);
Expand All @@ -1115,7 +1113,7 @@ bsl::span<TYPE, EXTENT>::last() const BSLS_KEYWORD_NOEXCEPT
template <class TYPE, size_t EXTENT>
BSLS_KEYWORD_CONSTEXPR_CPP14 inline
bsl::span<TYPE, bsl::dynamic_extent>
bsl::span<TYPE, EXTENT>::last(size_type count) const BSLS_KEYWORD_NOEXCEPT
bsl::span<TYPE, EXTENT>::last(size_type count) const
{
typedef bsl::span<TYPE, bsl::dynamic_extent> ReturnType;
BSLS_ASSERT(count <= size());
Expand All @@ -1134,7 +1132,6 @@ template <class TYPE, size_t EXTENT>
BSLS_KEYWORD_CONSTEXPR_CPP14 inline
bsl::span<TYPE, bsl::dynamic_extent>
bsl::span<TYPE, EXTENT>::subspan(size_type offset, size_type count) const
BSLS_KEYWORD_NOEXCEPT
{
typedef bsl::span<TYPE, bsl::dynamic_extent> ReturnType;
BSLS_ASSERT(offset <= size());
Expand Down Expand Up @@ -1312,7 +1309,7 @@ inline bsl::span<TYPE, bsl::dynamic_extent>::span(
bsl::vector<t_OTHER_TYPE, ALLOCATOR>& v,
typename bsl::enable_if<Span_Utility::IsArrayConvertible<
t_OTHER_TYPE, element_type>::value,
void *>::type)
void *>::type) BSLS_KEYWORD_NOEXCEPT
: d_data_p(v.data())
, d_size(v.size())
{
Expand All @@ -1324,7 +1321,7 @@ inline bsl::span<TYPE, bsl::dynamic_extent>::span(
const bsl::vector<t_OTHER_TYPE, ALLOCATOR>& v,
typename bsl::enable_if<Span_Utility::IsArrayConvertible<
const t_OTHER_TYPE, element_type>::value,
void *>::type)
void *>::type) BSLS_KEYWORD_NOEXCEPT
: d_data_p(v.data())
, d_size(v.size())
{
Expand All @@ -1336,7 +1333,7 @@ inline bsl::span<TYPE, bsl::dynamic_extent>::span(
bsl::basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& s,
typename bsl::enable_if<Span_Utility::IsArrayConvertible<
CHAR_TYPE, element_type>::value,
void *>::type)
void *>::type) BSLS_KEYWORD_NOEXCEPT
: d_data_p(s.data())
, d_size(s.size())
{
Expand All @@ -1348,7 +1345,7 @@ inline bsl::span<TYPE, bsl::dynamic_extent>::span(
const bsl::basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& s,
typename bsl::enable_if<Span_Utility::IsArrayConvertible<
const CHAR_TYPE, element_type>::value,
void *>::type)
void *>::type) BSLS_KEYWORD_NOEXCEPT
: d_data_p(s.data())
, d_size(s.size())
{
Expand All @@ -1360,7 +1357,7 @@ inline bsl::span<TYPE, bsl::dynamic_extent>::span(
const bsl::basic_string_view<CHAR_TYPE, CHAR_TRAITS>& sv,
typename bsl::enable_if<Span_Utility::IsArrayConvertible<
const CHAR_TYPE, element_type>::value,
void *>::type)
void *>::type) BSLS_KEYWORD_NOEXCEPT
: d_data_p(sv.data())
, d_size(sv.size())
{
Expand All @@ -1384,7 +1381,7 @@ bsl::span<TYPE, bsl::dynamic_extent>::span(
template <class TYPE>
BSLS_KEYWORD_CONSTEXPR_CPP14 inline
typename bsl::span<TYPE, bsl::dynamic_extent>::reference
bsl::span<TYPE, bsl::dynamic_extent>::back() const BSLS_KEYWORD_NOEXCEPT
bsl::span<TYPE, bsl::dynamic_extent>::back() const
{
BSLS_ASSERT(size() > 0);
return d_data_p[size() - 1];
Expand All @@ -1410,7 +1407,7 @@ template <class TYPE>
template <size_t COUNT>
BSLS_KEYWORD_CONSTEXPR_CPP14 inline
bsl::span<TYPE, COUNT>
bsl::span<TYPE, bsl::dynamic_extent>::first() const BSLS_KEYWORD_NOEXCEPT
bsl::span<TYPE, bsl::dynamic_extent>::first() const
{
typedef bsl::span<TYPE, COUNT> ReturnType;
BSLS_ASSERT(COUNT <= size());
Expand All @@ -1421,7 +1418,6 @@ template <class TYPE>
BSLS_KEYWORD_CONSTEXPR_CPP14 inline
bsl::span<TYPE, bsl::dynamic_extent>
bsl::span<TYPE, bsl::dynamic_extent>::first(size_type count) const
BSLS_KEYWORD_NOEXCEPT
{
typedef bsl::span<TYPE, bsl::dynamic_extent> ReturnType;
BSLS_ASSERT(count <= size());
Expand All @@ -1431,7 +1427,7 @@ bsl::span<TYPE, bsl::dynamic_extent>::first(size_type count) const
template <class TYPE>
BSLS_KEYWORD_CONSTEXPR_CPP14 inline
typename bsl::span<TYPE, bsl::dynamic_extent>::reference
bsl::span<TYPE, bsl::dynamic_extent>::front() const BSLS_KEYWORD_NOEXCEPT
bsl::span<TYPE, bsl::dynamic_extent>::front() const
{
BSLS_ASSERT(size() > 0);
return d_data_p[0];
Expand All @@ -1441,7 +1437,7 @@ template <class TYPE>
template <size_t COUNT>
BSLS_KEYWORD_CONSTEXPR_CPP14 inline
bsl::span<TYPE, COUNT>
bsl::span<TYPE, bsl::dynamic_extent>::last() const BSLS_KEYWORD_NOEXCEPT
bsl::span<TYPE, bsl::dynamic_extent>::last() const
{
typedef bsl::span<TYPE, COUNT> ReturnType;
BSLS_ASSERT(COUNT <= size());
Expand All @@ -1452,7 +1448,6 @@ template <class TYPE>
BSLS_KEYWORD_CONSTEXPR_CPP14 inline
bsl::span<TYPE, bsl::dynamic_extent>
bsl::span<TYPE, bsl::dynamic_extent>::last(size_type count) const
BSLS_KEYWORD_NOEXCEPT
{
typedef bsl::span<TYPE, bsl::dynamic_extent> ReturnType;
BSLS_ASSERT(count <= size());
Expand Down Expand Up @@ -1480,7 +1475,7 @@ template <class TYPE>
template <size_t OFFSET, size_t COUNT>
BSLS_KEYWORD_CONSTEXPR_CPP14 inline
bsl::span<TYPE, COUNT>
bsl::span<TYPE, bsl::dynamic_extent>::subspan() const BSLS_KEYWORD_NOEXCEPT
bsl::span<TYPE, bsl::dynamic_extent>::subspan() const
{
typedef bsl::span<TYPE, COUNT> ReturnType;
BSLS_ASSERT(OFFSET <= size());
Expand All @@ -1492,9 +1487,8 @@ bsl::span<TYPE, bsl::dynamic_extent>::subspan() const BSLS_KEYWORD_NOEXCEPT
template <class TYPE>
BSLS_KEYWORD_CONSTEXPR_CPP14 inline
bsl::span<TYPE, bsl::dynamic_extent>
bsl::span<TYPE, bsl::dynamic_extent>::subspan(
size_type offset,
size_type count) const BSLS_KEYWORD_NOEXCEPT
bsl::span<TYPE, bsl::dynamic_extent>::subspan(size_type offset,
size_type count) const
{
typedef bsl::span<TYPE, bsl::dynamic_extent> ReturnType;
BSLS_ASSERT(offset <= size());
Expand All @@ -1510,7 +1504,6 @@ template <class TYPE>
BSLS_KEYWORD_CONSTEXPR_CPP14 inline
typename bsl::span<TYPE, bsl::dynamic_extent>::reference
bsl::span<TYPE, bsl::dynamic_extent>::operator[](size_type index) const
BSLS_KEYWORD_NOEXCEPT
{
BSLS_ASSERT(index < size());
return d_data_p[index];
Expand Down
Loading

0 comments on commit abdd771

Please sign in to comment.