8#ifndef INCLUDED_BSLSTL_SPAN
9#define INCLUDED_BSLSTL_SPAN
184#include <bslscm_version.h>
189#ifdef BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY
192 using std::dynamic_extent;
195 using std::as_writable_bytes;
215#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
225template <
class TYPE,
size_t EXTENT = dynamic_extent>
class span;
248 template <
class FROM,
class TO>
253 template <
class TYPE,
size_t EXTENT,
size_t COUNT,
size_t OFFSET>
263 template <
class TYPE>
270#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
274 template <
class TP,
size_t SZ>
283 template <
class TP,
size_t SZ>
293 template <
class TP,
size_t SZ>
300 template <
class TP,
class ELEMENT_TYPE,
class =
void>
303 template <
class TP,
class ELEMENT_TYPE>
307 typename bsl::enable_if<!IsSpan<TP>::value, bsl::nullptr_t>::type,
309 typename bsl::enable_if<
310 !IsBSLArray<TP>::value, bsl::nullptr_t>::type,
312 typename bsl::enable_if<
313 !IsSTDArray<TP>::value, bsl::nullptr_t>::type,
315 typename bsl::enable_if<
316 !bsl::is_array<TP>::value, bsl::nullptr_t>::type,
318 decltype(bsl::data(std::declval<TP>())),
319 decltype(bsl::size(std::declval<TP>())),
321 typename bsl::enable_if<
322 Span_Utility::IsArrayConvertible<
323 typename bsl::remove_pointer<
324 decltype(bsl::data(std::declval<TP &>()))>::type,
325 ELEMENT_TYPE>::value,
326 bsl::nullptr_t>::type
333template <
class TYPE,
size_t EXTENT>
378 template <
size_t SIZE>
383#ifndef BSLSTL_ARRAY_IS_ALIASED
387 template <
class t_OTHER_TYPE>
397 template <
class t_OTHER_TYPE>
406#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
410 template <
class t_OTHER_TYPE>
412 std::array<t_OTHER_TYPE, EXTENT>& arr,
421 template <
class t_OTHER_TYPE>
423 const std::array<t_OTHER_TYPE, EXTENT>& arr,
433 template <
class t_OTHER_TYPE>
445 template <
class t_OTHER_TYPE>
464 return d_data_p[
size() - 1];
477 template <
size_t COUNT>
500 template <
size_t COUNT>
528 template <
size_t OFFSET,
529#ifdef BSLS_COMPILERFEATURES_SUPPORT_DEFAULT_TEMPLATE_ARGS
544 return ReturnType(
data() + OFFSET,
565 return d_data_p[index];
647 template <
size_t SIZE>
652#ifndef BSLSTL_ARRAY_IS_ALIASED
656 template <
class t_OTHER_TYPE,
size_t SIZE>
666 template <
class t_OTHER_TYPE,
size_t SIZE>
675#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
679 template <
class t_OTHER_TYPE,
size_t SIZE>
689 template <
class t_OTHER_TYPE,
size_t SIZE>
691 const std::array<t_OTHER_TYPE, SIZE>& arr,
698#ifndef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
702 template <
class t_OTHER_TYPE,
class ALLOCATOR>
712 template <
class t_OTHER_TYPE,
class ALLOCATOR>
722 template<
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
732 template<
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
742 template<
class CHAR_TYPE,
class CHAR_TRAITS>
750#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
751 template <
class CONTAINER>
756 void *>::type = NULL)
762 template <
class CONTAINER>
767 void *>::type = NULL)
777 template <
class t_OTHER_TYPE,
size_t OTHER_EXTENT>
802 template <
size_t COUNT>
820 template <
size_t COUNT>
840 template <
size_t OFFSET,
841#ifdef BSLS_COMPILERFEATURES_SUPPORT_DEFAULT_TEMPLATE_ARGS
892 d_data_p = rhs.d_data_p;
907#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
912template <
class TYPE,
size_t SIZE>
915#ifndef BSLSTL_ARRAY_IS_ALIASED
919template <
class TYPE,
size_t SIZE>
925template <
class TYPE,
size_t SIZE>
932template <
class TYPE,
size_t SIZE>
938template <
class TYPE,
size_t SIZE>
943template <
class TYPE,
class ALLOCATOR>
948template <
class TYPE,
class ALLOCATOR>
953#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
957template <
class TYPE,
size_t EXTENT>
969template <
class TYPE,
size_t EXTENT>
983template <
class TYPE,
size_t EXTENT>
999template <
class TYPE,
size_t EXTENT>
1007template <
class TYPE,
size_t EXTENT>
1010: d_data_p(original.d_data_p)
1014template <
class TYPE,
size_t EXTENT>
1023template <
class TYPE,
size_t EXTENT>
1033template <
class TYPE,
size_t EXTENT>
1034template <
size_t SIZE>
1044#ifndef BSLSTL_ARRAY_IS_ALIASED
1045template <
class TYPE,
size_t EXTENT>
1046template <
class t_OTHER_TYPE>
1052: d_data_p(arr.data())
1056template <
class TYPE,
size_t EXTENT>
1057template <
class t_OTHER_TYPE>
1064: d_data_p(arr.data())
1069#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
1070template <
class TYPE,
size_t EXTENT>
1071template <
class t_OTHER_TYPE>
1077: d_data_p(arr.data())
1081template <
class TYPE,
size_t EXTENT>
1082template <
class t_OTHER_TYPE>
1088: d_data_p(arr.data())
1093template <
class TYPE,
size_t EXTENT>
1094template <
class t_OTHER_TYPE>
1100: d_data_p(other.data())
1105template <
class TYPE,
size_t EXTENT>
1106template <
class t_OTHER_TYPE>
1113: d_data_p(other.data())
1119template <
class TYPE,
size_t EXTENT>
1127template <
class TYPE,
size_t EXTENT>
1134template <
class TYPE,
size_t EXTENT>
1135template <
size_t COUNT>
1142 return ReturnType(
data(), COUNT);
1145template <
class TYPE,
size_t EXTENT>
1152 return ReturnType(
data(), count);
1155template <
class TYPE,
size_t EXTENT>
1156template <
size_t COUNT>
1163 return ReturnType(
data() +
size() - COUNT, COUNT);
1166template <
class TYPE,
size_t EXTENT>
1173 return ReturnType(
data() +
size() - count, count);
1176template <
class TYPE,
size_t EXTENT>
1184template <
class TYPE,
size_t EXTENT>
1193 return ReturnType(
data() + offset,
size() - offset);
1196 return ReturnType(
data() + offset, count);
1200template <
class TYPE,
size_t EXTENT>
1208template <
class TYPE,
size_t EXTENT>
1216template <
class TYPE,
size_t EXTENT>
1224template <
class TYPE,
size_t EXTENT>
1233template <
class TYPE,
size_t EXTENT>
1238 d_data_p = rhs.d_data_p;
1242template <
class TYPE,
size_t EXTENT>
1247 d_data_p = other.d_data_p;
1256template <
class TYPE>
1264template <
class TYPE>
1268: d_data_p(original.d_data_p)
1269, d_size(original.d_size)
1273template <
class TYPE>
1281template <
class TYPE>
1285, d_size(
bsl::distance(first, last))
1290template <
class TYPE>
1291template <
size_t SIZE>
1301#ifndef BSLSTL_ARRAY_IS_ALIASED
1302template <
class TYPE>
1303template <
class t_OTHER_TYPE,
size_t SIZE>
1308 Span_Utility::IsArrayConvertible<t_OTHER_TYPE, element_type>::value,
1310: d_data_p(arr.data())
1315template <
class TYPE>
1316template <
class t_OTHER_TYPE,
size_t SIZE>
1321 Span_Utility::IsArrayConvertible<const t_OTHER_TYPE, element_type>::value,
1323: d_data_p(arr.data())
1329#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
1330template <
class TYPE>
1331template <
class t_OTHER_TYPE,
size_t SIZE>
1334 std::array<t_OTHER_TYPE, SIZE>& arr,
1336 Span_Utility::IsArrayConvertible<t_OTHER_TYPE, element_type>::value,
1338: d_data_p(arr.data())
1343template <
class TYPE>
1344template <
class t_OTHER_TYPE,
size_t SIZE>
1347 const std::array<t_OTHER_TYPE, SIZE>& arr,
1349 Span_Utility::IsArrayConvertible<
1350 const t_OTHER_TYPE, element_type>::value,
1352: d_data_p(arr.data())
1358#ifndef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
1359template <
class TYPE>
1360template <
class t_OTHER_TYPE,
class ALLOCATOR>
1364 t_OTHER_TYPE, element_type>::value,
1371template <
class TYPE>
1372template <
class t_OTHER_TYPE,
class ALLOCATOR>
1376 const t_OTHER_TYPE, element_type>::value,
1383template <
class TYPE>
1384template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
1388 CHAR_TYPE, element_type>::value,
1395template <
class TYPE>
1396template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
1400 const CHAR_TYPE, element_type>::value,
1407template <
class TYPE>
1408template <
class CHAR_TYPE,
class CHAR_TRAITS>
1412 const CHAR_TYPE, element_type>::value,
1414: d_data_p(sv.data())
1420template <
class TYPE>
1421template <
class t_OTHER_TYPE,
size_t OTHER_EXTENT>
1426 Span_Utility::IsArrayConvertible<t_OTHER_TYPE, element_type>::value,
1428: d_data_p(other.data())
1429, d_size(other.size())
1434template <
class TYPE>
1440 return d_data_p[
size() - 1];
1443template <
class TYPE>
1451template <
class TYPE>
1459template <
class TYPE>
1460template <
size_t COUNT>
1467 return ReturnType(
data(), COUNT);
1470template <
class TYPE>
1477 return ReturnType(
data(), count);
1480template <
class TYPE>
1489template <
class TYPE>
1490template <
size_t COUNT>
1497 return ReturnType(
data() +
size() - COUNT, COUNT);
1500template <
class TYPE>
1507 return ReturnType(
data() +
size() - count, count);
1510template <
class TYPE>
1518template <
class TYPE>
1524 return size() *
sizeof(element_type);
1527template <
class TYPE>
1528template <
size_t OFFSET,
size_t COUNT>
1536 return ReturnType(
data() + OFFSET,
1540template <
class TYPE>
1544 size_type count)
const
1550 return ReturnType(
data() + offset,
size() - offset);
1553 return ReturnType(
data() + offset, count);
1556template <
class TYPE>
1562 return d_data_p[index];
1566template <
class TYPE>
1571 pointer p = d_data_p;
1572 d_data_p = other.d_data_p;
1576 d_size = other.d_size;
1581template <
class TYPE>
1586 return iterator(
data());
1589template <
class TYPE>
1597template <
class TYPE>
1602 return reverse_iterator(
end());
1605template <
class TYPE>
1610 return reverse_iterator(
begin());
1614#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
1618template <
class TYPE,
size_t EXTENT>
1620bsl::span<
const std::byte, EXTENT *
sizeof(TYPE)>
1624 reinterpret_cast<const std::byte *
>(s.data()),
1628template <
class TYPE>
1634 reinterpret_cast<const std::byte *
>(s.data()),
1638template <
class TYPE,
size_t EXTENT>
1640bsl::span<std::byte, EXTENT *
sizeof(TYPE)>
1644 reinterpret_cast<std::byte *
>(s.data()),
1648template <
class TYPE>
1655 reinterpret_cast<std::byte *
>(s.data()),
1662template <
class TYPE,
size_t EXTENT>
Definition bslstl_stringview.h:441
Definition bslstl_string.h:1281
~span() noexcept=default
Destroy this object.
bsl::reverse_iterator< iterator > reverse_iterator
Definition bslstl_span.h:621
bsl::remove_cv< TYPE >::type value_type
Definition bslstl_span.h:613
const TYPE * const_pointer
Definition bslstl_span.h:617
BSLS_KEYWORD_CONSTEXPR_CPP14 span< element_type, dynamic_extent > subspan(size_type offset, size_type count=dynamic_extent) const
BSLS_KEYWORD_CONSTEXPR_CPP14 span(const span< t_OTHER_TYPE, OTHER_EXTENT > &other, typename bsl::enable_if< Span_Utility::IsArrayConvertible< t_OTHER_TYPE, element_type >::value, void * >::type=NULL) BSLS_KEYWORD_NOEXCEPT
BSLS_KEYWORD_CONSTEXPR_CPP14 span(const std::array< t_OTHER_TYPE, SIZE > &arr, typename bsl::enable_if< Span_Utility::IsArrayConvertible< const t_OTHER_TYPE, element_type >::value, void * >::type=NULL) BSLS_KEYWORD_NOEXCEPT
TYPE * pointer
Definition bslstl_span.h:616
BSLS_KEYWORD_CONSTEXPR_CPP14 span(const bsl::array< t_OTHER_TYPE, SIZE > &arr, typename bsl::enable_if< Span_Utility::IsArrayConvertible< const t_OTHER_TYPE, element_type >::value, void * >::type=NULL) BSLS_KEYWORD_NOEXCEPT
const TYPE & const_reference
Definition bslstl_span.h:619
BSLS_KEYWORD_CONSTEXPR_CPP14 span(bsl::array< t_OTHER_TYPE, SIZE > &arr, typename bsl::enable_if< Span_Utility::IsArrayConvertible< t_OTHER_TYPE, element_type >::value, void * >::type=NULL) BSLS_KEYWORD_NOEXCEPT
BSLS_KEYWORD_CONSTEXPR_CPP14 span(const CONTAINER &c, typename bsl::enable_if< Span_Utility::IsSpanCompatibleContainer< const CONTAINER, TYPE >::value, void * >::type=NULL)
Definition bslstl_span.h:763
BSLS_KEYWORD_CONSTEXPR_CPP14 span(std::array< t_OTHER_TYPE, SIZE > &arr, typename bsl::enable_if< Span_Utility::IsArrayConvertible< t_OTHER_TYPE, element_type >::value, void * >::type=NULL) BSLS_KEYWORD_NOEXCEPT
pointer iterator
Definition bslstl_span.h:620
BSLS_KEYWORD_CONSTEXPR_CPP14 iterator begin() const BSLS_KEYWORD_NOEXCEPT
BSLS_KEYWORD_CONSTEXPR_CPP14 span(CONTAINER &c, typename bsl::enable_if< Span_Utility::IsSpanCompatibleContainer< CONTAINER, TYPE >::value, void * >::type=NULL)
Definition bslstl_span.h:752
BSLS_KEYWORD_CONSTEXPR_CPP14 reference operator[](size_type index) const
TYPE & reference
Definition bslstl_span.h:618
BSLS_KEYWORD_CONSTEXPR_CPP14 span< element_type, COUNT > subspan() const
TYPE element_type
Definition bslstl_span.h:612
BSLS_KEYWORD_CONSTEXPR_CPP14 span() BSLS_KEYWORD_NOEXCEPT
Construct an empty span object.
ptrdiff_t difference_type
Definition bslstl_span.h:615
BSLS_KEYWORD_CONSTEXPR_CPP14 void swap(span &other) BSLS_KEYWORD_NOEXCEPT
size_t size_type
Definition bslstl_span.h:614
Definition bslstl_span.h:334
const TYPE & const_reference
Definition bslstl_span.h:345
~span() noexcept=default
Destroy this object.
bsl::remove_cv< TYPE >::type value_type
Definition bslstl_span.h:339
ptrdiff_t difference_type
Definition bslstl_span.h:341
TYPE element_type
Definition bslstl_span.h:338
static const size_type extent
Definition bslstl_span.h:352
BSLS_KEYWORD_CONSTEXPR_CPP14 Span_Utility::SubspanReturnType< TYPE, EXTENT, COUNT, OFFSET >::type subspan() const
Definition bslstl_span.h:536
BSLS_KEYWORD_CONSTEXPR_CPP14 span(const span< t_OTHER_TYPE, dynamic_extent > &other, typename bsl::enable_if< Span_Utility::IsArrayConvertible< t_OTHER_TYPE, element_type >::value, void * >::type=NULL) BSLS_KEYWORD_NOEXCEPT
BSLS_KEYWORD_CONSTEXPR_CPP14 span< element_type, COUNT > first() const
TYPE * pointer
Definition bslstl_span.h:342
bsl::reverse_iterator< iterator > reverse_iterator
Definition bslstl_span.h:347
BSLS_KEYWORD_CONSTEXPR_CPP14 span< element_type, COUNT > last() const
TYPE & reference
Definition bslstl_span.h:344
size_t size_type
Definition bslstl_span.h:340
const TYPE * const_pointer
Definition bslstl_span.h:343
pointer iterator
Definition bslstl_span.h:346
Definition bslstl_vector.h:1025
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:229
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_KEYWORD_CONSTEXPR_CPP14
Definition bsls_keyword.h:595
#define BSLS_KEYWORD_CONSTEXPR
Definition bsls_keyword.h:588
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:632
BSLS_KEYWORD_CONSTEXPR pointer data() const BSLS_KEYWORD_NOEXCEPT
Return a pointer to the data referenced by this span.
Definition bslstl_span.h:1122
BSLS_KEYWORD_CONSTEXPR_CPP14 iterator begin() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_span.h:1203
BSLS_KEYWORD_CONSTEXPR_CPP14 reverse_iterator rbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_span.h:1219
BSLS_KEYWORD_CONSTEXPR size_type size_bytes() const BSLS_KEYWORD_NOEXCEPT
Return the size of this span in bytes.
Definition bslstl_span.h:1179
BSLS_KEYWORD_CONSTEXPR_CPP14 span & operator=(const span &) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_span.h:1236
BSLS_KEYWORD_CONSTEXPR_CPP14 reference front() const
Definition bslstl_span.h:490
BSLS_KEYWORD_CONSTEXPR_CPP14 reference operator[](size_type index) const
Definition bslstl_span.h:561
BSLS_KEYWORD_CONSTEXPR_CPP14 iterator end() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_span.h:1211
BSLS_KEYWORD_CONSTEXPR_CPP14 reverse_iterator rend() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_span.h:1227
BSLS_KEYWORD_CONSTEXPR size_type size() const BSLS_KEYWORD_NOEXCEPT
Return the size of this span.
Definition bslstl_span.h:512
BSLS_KEYWORD_CONSTEXPR_CPP14 reference back() const
Definition bslstl_span.h:460
BSLS_KEYWORD_CONSTEXPR_CPP14 void swap(span &other) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_span.h:1244
BSLS_KEYWORD_CONSTEXPR bool empty() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_span.h:1129
BSLS_KEYWORD_CONSTEXPR_CPP14 span() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_span.h:1001
Definition bdlb_printmethods.h:283
void swap(array< VALUE_TYPE, SIZE > &lhs, array< VALUE_TYPE, SIZE > &rhs)
@ dynamic_extent
Definition bslstl_span.h:223
T::iterator begin(T &container)
Definition bslstl_iterator.h:1495
BSLS_KEYWORD_CONSTEXPR size_t size(const TYPE(&)[DIMENSION]) BSLS_KEYWORD_NOEXCEPT
Return the dimension of the specified array argument.
Definition bslstl_iterator.h:1331
T::iterator end(T &container)
Definition bslstl_iterator.h:1523
BSLS_KEYWORD_CONSTEXPR CONTAINER::value_type * data(CONTAINER &container)
Definition bslstl_iterator.h:1231
Definition bdldfp_decimal.h:5188
Definition bslstl_span.h:250
Definition bslstl_span.h:281
Definition bslstl_span.h:288
Definition bslstl_span.h:291
Definition bslstl_span.h:298
Definition bslstl_span.h:301
Definition bslstl_span.h:272
Definition bslstl_span.h:278
Definition bslstl_span.h:255
bsl::span< TYPE, COUNT !=dynamic_extent ? COUNT :EXTENT - OFFSET > type
Definition bslstl_span.h:259
Definition bslstl_span.h:265
TYPE type
Definition bslstl_span.h:267
Definition bslstl_span.h:235
Definition bslstl_array.h:290
Definition bslmf_enableif.h:525
Definition bslmf_integralconstant.h:244
Definition bslmf_isconvertible.h:867
remove_const< typenameremove_volatile< t_TYPE >::type >::type type
Definition bslmf_removecv.h:126