8#ifndef INCLUDED_BSLSTL_ARRAY
9#define INCLUDED_BSLSTL_ARRAY
203#include <bslscm_version.h>
233#if defined(BSLS_LIBRARYFEATURES_HAS_CPP11_TUPLE)
237#if defined(BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY)
243#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
247#ifndef BDE_DISABLE_CPP17_ABI
248#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
258#define BSLSTL_ARRAY_IS_ALIASED
263#ifndef BSLSTL_ARRAY_IS_ALIASED
267#if defined(BSLS_COMPILERFEATURES_SUPPORT_CONSTEXPR_CPP14) \
268 && defined(BSLS_PLATFORM_CMP_GNU) && BSLS_PLATFORM_CMP_VERSION < 60000
277# define BSLSTL_ARRAY_DISABLE_CONSTEXPR_CONTRACTS 1
289template <
class VALUE_TYPE,
size_t SIZE>
296 VALUE_TYPE
d_data[(0 == SIZE) ? 1 : SIZE];
341 void fill(
const VALUE_TYPE& value);
348 bsl::is_nothrow_swappable<VALUE_TYPE>::value);
476#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
484template<
class VALUE_TYPE,
486 class = bsl::enable_if_t<(bsl::is_same_v<VALUE_TYPE, OTHERS> && ...)>
488array(VALUE_TYPE, OTHERS...) ->
array<VALUE_TYPE, 1 +
sizeof...(OTHERS)>;
497template <
class VALUE_TYPE,
size_t SIZE>
501#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
508template <
class VALUE_TYPE,
size_t SIZE>
514#ifdef BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
519template <
class VALUE_TYPE,
size_t SIZE>
520BloombergLP::bslalg::SynthThreeWayUtil::Result<VALUE_TYPE> operator<=>(
529template <
class VALUE_TYPE,
size_t SIZE>
536template <
class VALUE_TYPE,
size_t SIZE>
543template <
class VALUE_TYPE,
size_t SIZE>
550template <
class VALUE_TYPE,
size_t SIZE>
560template <
class VALUE_TYPE,
size_t SIZE>
566template<
size_t INDEX,
class TYPE,
size_t SIZE>
573template<
size_t INDEX,
class TYPE,
size_t SIZE>
577#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
581template<
size_t INDEX,
class TYPE,
size_t SIZE>
589template<
size_t INDEX,
class TYPE,
size_t SIZE>
597template <
class HASH_ALGORITHM,
class TYPE,
size_t SIZE>
602#if defined(BSLS_LIBRARYFEATURES_HAS_CPP11_TUPLE)
606#if defined(BSLS_PLATFORM_CMP_CLANG)
607#pragma clang diagnostic push
608#pragma clang diagnostic ignored "-Wmismatched-tags"
622template<
size_t INDEX,
class TYPE,
size_t SIZE>
623struct tuple_element<INDEX,
bsl::array<TYPE, SIZE> >
639template<
class TYPE,
size_t SIZE>
640struct tuple_size<
bsl::array<TYPE, SIZE> > : integral_constant<size_t, SIZE>
644#if defined(BSLS_PLATFORM_CMP_CLANG)
645#pragma clang diagnostic pop
653#ifdef BSLSTL_ARRAY_IS_ALIASED
668template <
class HASH_ALGORITHM,
class TYPE,
size_t SIZE>
670 const std::array<TYPE, SIZE>& input);
681#ifndef BSLSTL_ARRAY_IS_ALIASED
691#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
692#pragma GCC diagnostic push
693#pragma GCC diagnostic ignored "-Wtype-limits"
696template <
class VALUE_TYPE,
size_t SIZE>
699 for (
size_t i = 0; i < SIZE; ++i) {
704template <
class VALUE_TYPE,
size_t SIZE>
707 bsl::is_nothrow_swappable<VALUE_TYPE>::value)
709 for (
size_t i = 0; i < SIZE; ++i) {
711 swap(d_data[i], rhs.d_data[i]);
716#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
717#pragma GCC diagnostic pop
721template <
class VALUE_TYPE,
size_t SIZE>
729template <
class VALUE_TYPE,
size_t SIZE>
737template <
class VALUE_TYPE,
size_t SIZE>
742 return d_data + SIZE;
745template <
class VALUE_TYPE,
size_t SIZE>
750 return d_data + SIZE;
753template <
class VALUE_TYPE,
size_t SIZE>
761template <
class VALUE_TYPE,
size_t SIZE>
769template <
class VALUE_TYPE,
size_t SIZE>
777template <
class VALUE_TYPE,
size_t SIZE>
785template <
class VALUE_TYPE,
size_t SIZE>
793template <
class VALUE_TYPE,
size_t SIZE>
798 return d_data + SIZE;
801template <
class VALUE_TYPE,
size_t SIZE>
809template <
class VALUE_TYPE,
size_t SIZE>
817template <
class VALUE_TYPE,
size_t SIZE>
824template <
class VALUE_TYPE,
size_t SIZE>
831template <
class VALUE_TYPE,
size_t SIZE>
838template <
class VALUE_TYPE,
size_t SIZE>
844 return d_data[position];
847template <
class VALUE_TYPE,
size_t SIZE>
852#if !defined(BSLSTL_ARRAY_DISABLE_CONSTEXPR_CONTRACTS)
856 return d_data[position];
859template <
class VALUE_TYPE,
size_t SIZE>
864 if (position >= SIZE) {
865 BloombergLP::bslstl::StdExceptUtil::throwOutOfRange(
866 "array<...>::at(position): invalid position");
868 return d_data[position];
871template <
class VALUE_TYPE,
size_t SIZE>
876 if (position >= SIZE) {
877 BloombergLP::bslstl::StdExceptUtil::throwOutOfRange(
878 "array<...>::at(position): invalid position");
880 return d_data[position];
883template <
class VALUE_TYPE,
size_t SIZE>
892template <
class VALUE_TYPE,
size_t SIZE>
897#if !defined(BSLSTL_ARRAY_DISABLE_CONSTEXPR_CONTRACTS)
904template <
class VALUE_TYPE,
size_t SIZE>
910 return d_data[SIZE - 1];
913template <
class VALUE_TYPE,
size_t SIZE>
918#if !defined(BSLSTL_ARRAY_DISABLE_CONSTEXPR_CONTRACTS)
922 return d_data[SIZE - 1];
925template <
class VALUE_TYPE,
size_t SIZE>
933template <
class VALUE_TYPE,
size_t SIZE>
944#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
945#pragma GCC diagnostic push
946#pragma GCC diagnostic ignored "-Wtype-limits"
949template <
class HASH_ALGORITHM,
class TYPE,
size_t SIZE>
952 using ::BloombergLP::bslh::hashAppend;
955 for (
size_t i = 0; i < SIZE; ++i)
962#ifdef BSLS_PLATFORM_HAS_PRAGMA_GCC_DIAGNOSTIC
963#pragma GCC diagnostic pop
968template <
class VALUE_TYPE,
size_t SIZE>
970 const array<VALUE_TYPE, SIZE>& rhs)
972 return BloombergLP::bslalg::RangeCompare::equal(lhs.begin(),
980#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
982template <
class VALUE_TYPE,
size_t SIZE>
984 const array<VALUE_TYPE, SIZE>& rhs)
986 return !(lhs == rhs);
991#ifdef BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
993template <
class VALUE_TYPE,
size_t SIZE>
994BloombergLP::bslalg::SynthThreeWayUtil::Result<VALUE_TYPE> bsl::operator<=>(
995 const array<VALUE_TYPE, SIZE>& lhs,
996 const array<VALUE_TYPE, SIZE>& rhs)
998 return bsl::lexicographical_compare_three_way(
1003 BloombergLP::bslalg::SynthThreeWayUtil::compare);
1008template <
class VALUE_TYPE,
size_t SIZE>
1010 const array<VALUE_TYPE, SIZE>& rhs)
1012 return 0 > BloombergLP::bslalg::RangeCompare::lexicographical(lhs.begin(),
1020template <
class VALUE_TYPE,
size_t SIZE>
1022 const array<VALUE_TYPE, SIZE>& rhs)
1027template <
class VALUE_TYPE,
size_t SIZE>
1029 const array<VALUE_TYPE, SIZE>& rhs)
1031 return !(rhs < lhs);
1034template <
class VALUE_TYPE,
size_t SIZE>
1036 const array<VALUE_TYPE, SIZE>& rhs)
1038 return !(lhs < rhs);
1044template <
class VALUE_TYPE,
size_t SIZE>
1045void bsl::swap(array<VALUE_TYPE, SIZE>& lhs, array<VALUE_TYPE, SIZE>& rhs)
1050template<
size_t INDEX,
class TYPE,
size_t SIZE>
1054 return a.d_data[INDEX];
1057template<
size_t INDEX,
class TYPE,
size_t SIZE>
1061 return a.d_data[INDEX];
1064#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
1065template<
size_t INDEX,
class TYPE,
size_t SIZE>
1069 return BloombergLP::bslmf::MovableRefUtil::move(a.d_data[INDEX]);
1072template<
size_t INDEX,
class TYPE,
size_t SIZE>
1076 return BloombergLP::bslmf::MovableRefUtil::move(a.d_data[INDEX]);
1083#ifdef BSLSTL_ARRAY_IS_ALIASED
1088template <
class HASH_ALGORITHM,
class TYPE,
size_t SIZE>
1089void hashAppend(HASH_ALGORITHM& hashAlgorithm,
1090 const std::array<TYPE, SIZE>& input)
1092 using ::BloombergLP::bslh::hashAppend;
1096 for (
size_t i = 0; i < SIZE; ++i) {
1107#if defined(BSLSTL_ARRAY_IS_ALIASED) \
1108 && defined(BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY)
1122template<
class TYPE, std::
size_t SIZE >
1126#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
1127template<
class TYPE, std::
size_t SIZE >
1143#if defined(BSLS_COMPILERFEATURES_SUPPORT_VARIADIC_TEMPLATES) \
1144 && defined(BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES)
1146namespace bslstl_to_array_impl {
1148template <
class TYPE, std::size_t SIZE, std::size_t... INDICES>
1151to_array_lvalue_builder(TYPE (&src)[SIZE], std::index_sequence<INDICES...>)
1155 return {{src[INDICES]...}};
1158template <
class TYPE, std::size_t SIZE, std::size_t... INDICES>
1161to_array_rvalue_builder(TYPE(&&src)[SIZE], std::index_sequence<INDICES...>)
1165 return {{std::move(src[INDICES])...}};
1171template <
class TYPE, std::
size_t SIZE>
1180 return BloombergLP::bslstl_to_array_impl::to_array_lvalue_builder(
1182 std::make_index_sequence<SIZE>());
1185template <
class TYPE, std::
size_t SIZE>
1194 return BloombergLP::bslstl_to_array_impl::to_array_rvalue_builder(
1196 std::make_index_sequence<SIZE>());
1201template <
class TYPE, std::
size_t SIZE>
1209 array<typename remove_cv<TYPE>::type, SIZE> result;
1211 for (std::size_t i = 0; i < SIZE; ++i) {
1218#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
1219template <
class TYPE, std::
size_t SIZE>
1227 array<typename remove_cv<TYPE>::type, SIZE> result;
1229 for (std::size_t i = 0; i < SIZE; ++i) {
1230 result[i] = std::move(src[i]);
1251template <
class TYPE,
size_t SIZE>
Definition bdlb_pcgrandomgenerator.h:242
#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_CPP17
Definition bsls_keyword.h:603
#define BSLS_KEYWORD_CONSTEXPR
Definition bsls_keyword.h:588
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:632
#define BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(...)
Definition bsls_keyword.h:634
void hashAppend(HASH_ALGORITHM &hashAlg, const baljsn::EncoderTestAddress &object)
Definition baljsn_encoder_testtypes.h:9236
Definition bdlb_printmethods.h:283
void swap(array< VALUE_TYPE, SIZE > &lhs, array< VALUE_TYPE, SIZE > &rhs)
bool operator<(const array< VALUE_TYPE, SIZE > &lhs, const array< VALUE_TYPE, SIZE > &rhs)
void hashAppend(HASH_ALGORITHM &hashAlgorithm, const array< TYPE, SIZE > &input)
Pass the specified input to the specified hashAlgorithm
Definition bslstl_array.h:950
bool operator>(const array< VALUE_TYPE, SIZE > &lhs, const array< VALUE_TYPE, SIZE > &rhs)
BSLS_KEYWORD_CONSTEXPR_CPP14 TYPE & get(array< TYPE, SIZE > &a) BSLS_KEYWORD_NOEXCEPT
bool operator>=(const array< VALUE_TYPE, SIZE > &lhs, const array< VALUE_TYPE, SIZE > &rhs)
bool operator<=(const array< VALUE_TYPE, SIZE > &lhs, const array< VALUE_TYPE, SIZE > &rhs)
bool operator==(const memory_resource &a, const memory_resource &b)
BSLS_KEYWORD_CONSTEXPR_CPP14 array< typename remove_cv< TYPE >::type, SIZE > to_array(TYPE(&src)[SIZE])
bool operator!=(const memory_resource &a, const memory_resource &b)
Definition bdlc_flathashmap.h:1805
Definition bslh_defaulthashalgorithm.h:339
Definition bdldfp_decimal.h:5188
void swap(TYPE &a, TYPE &b)
Definition bslstl_array.h:290
BSLS_KEYWORD_CONSTEXPR_CPP14 reference front()
Definition bslstl_array.h:886
size_t size_type
Definition bslstl_array.h:306
void fill(const VALUE_TYPE &value)
Definition bslstl_array.h:697
BSLS_KEYWORD_CONSTEXPR size_type max_size() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_array.h:833
VALUE_TYPE d_data[(0==SIZE) ? 1 :SIZE]
Definition bslstl_array.h:296
BSLS_KEYWORD_CONSTEXPR_CPP14 pointer data() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_array.h:928
bsl::reverse_iterator< iterator > reverse_iterator
Definition bslstl_array.h:310
BSLS_KEYWORD_CONSTEXPR_CPP14 const_iterator cend() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_array.h:796
VALUE_TYPE * pointer
Definition bslstl_array.h:302
array(const array &original)=default
array(array &&original)=default
const VALUE_TYPE & const_reference
Definition bslstl_array.h:305
VALUE_TYPE value_type
Definition bslstl_array.h:301
BSLS_KEYWORD_CONSTEXPR_CPP17 const_reverse_iterator crend() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_array.h:812
ptrdiff_t difference_type
Definition bslstl_array.h:307
BSLS_KEYWORD_CONSTEXPR_CPP14 reference back()
Definition bslstl_array.h:907
BSLS_KEYWORD_CONSTEXPR_CPP14 iterator end() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_array.h:740
BSLS_KEYWORD_CONSTEXPR_CPP17 reverse_iterator rend() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_array.h:772
BSLS_KEYWORD_CONSTEXPR_CPP14 reference operator[](size_type position)
Definition bslstl_array.h:841
BSLS_KEYWORD_CONSTEXPR bool empty() const BSLS_KEYWORD_NOEXCEPT
Return true if the array has size 0, and false otherwise.
Definition bslstl_array.h:819
bsl::reverse_iterator< const_iterator > const_reverse_iterator
Definition bslstl_array.h:311
BSLS_KEYWORD_CONSTEXPR_CPP17 reverse_iterator rbegin() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_array.h:756
void swap(array &rhs) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl BSLS_KEYWORD_CONSTEXPR_CPP14 iterator begin() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_array.h:354
const VALUE_TYPE * const_pointer
Definition bslstl_array.h:303
VALUE_TYPE & reference
Definition bslstl_array.h:304
BSLS_KEYWORD_CONSTEXPR_CPP14 reference at(size_type position)
Definition bslstl_array.h:861
BSLS_KEYWORD_CONSTEXPR_CPP17 const_reverse_iterator crbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_array.h:804
const_pointer const_iterator
Definition bslstl_array.h:309
pointer iterator
Definition bslstl_array.h:308
BSLS_KEYWORD_CONSTEXPR size_type size() const BSLS_KEYWORD_NOEXCEPT
Return the number of elements in this array.
Definition bslstl_array.h:826
BSLS_KEYWORD_CONSTEXPR_CPP14 const_iterator cbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_array.h:788
Definition bslmf_isarray.h:168
Definition bslmf_iscopyconstructible.h:242
Definition bslalg_hasstliterators.h:99