8#ifndef INCLUDED_BSLTF_TESTVALUESARRAY
9#define INCLUDED_BSLTF_TESTVALUESARRAY
196#include <bslscm_version.h>
212#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
220template <
class VALUE,
class ALLOCATOR>
221struct TestValuesArray_DefaultConverter;
223template <
class VALUE>
224class TestValuesArray_PostIncrementPtr;
226template <
class VALUE>
227class TestValuesArraySentinel;
250template <
class VALUE>
254 const VALUE *d_data_p;
257 const VALUE *d_end_p;
260 bool *d_dereferenceable_p;
269 template <
class OTHER_VALUE>
273 template <
class OTHER_VALUE>
277 template <
class OTHER_VALUE>
281 template <
class OTHER_VALUE>
285 template <
class OTHER_VALUE>
289 template <
class OTHER_VALUE>
320 bool *dereferenceable,
372template <
class VALUE>
380template <
class VALUE>
388template <
class VALUE>
391 const VALUE *d_end_p;
394 template <
class OTHER_VALUE>
398 template <
class OTHER_VALUE>
402 template <
class OTHER_VALUE>
406 template <
class OTHER_VALUE>
435template <
class VALUE>
438template <
class VALUE>
446template <
class VALUE>
449template <
class VALUE>
463template <
class VALUE,
466 bool USE_SENTINEL =
false>
472 rebind_traits<bsls::AlignmentUtil::MaxAlignedType>
474 typedef typename AllocatorTraits::allocator_type AllocatorType;
475 typedef typename AllocatorTraits::size_type size_type;
478 ALLOCATOR d_allocator;
485 bool *d_dereferenceable_p;
488 bool *d_validIterator_p;
500 void initialize(
const char *spec);
581 const VALUE *
data()
const;
600template <
class VALUE,
class ALLOCATOR>
612 static void createInplace(VALUE *objPtr,
char value, ALLOCATOR allocator);
623template <
class VALUE>
628 const VALUE *d_data_p;
654template <
class VALUE>
659, d_dereferenceable_p(0)
664template <
class VALUE>
669 bool *dereferenceable,
673, d_dereferenceable_p(dereferenceable)
674, d_isValid_p(isValid)
683template <
class VALUE>
687: d_data_p(original.d_data_p)
688, d_end_p(original.d_end_p)
689, d_dereferenceable_p(original.d_dereferenceable_p)
690, d_isValid_p(original.d_isValid_p)
696template <
class VALUE>
702 d_data_p = other.d_data_p;
703 d_end_p = other.d_end_p;
704 d_dereferenceable_p = other.d_dereferenceable_p;
705 d_isValid_p = other.d_isValid_p;
710template <
class VALUE>
717 *d_dereferenceable_p =
false;
718 *d_isValid_p =
false;
721 ++d_dereferenceable_p;
726template <
class VALUE>
739template <
class VALUE>
746 *d_dereferenceable_p =
false;
750template <
class VALUE>
757 *d_dereferenceable_p =
false;
761template <
class VALUE>
772template <
class VALUE>
778template <
class VALUE>
785template <
class VALUE>
794template <
class VALUE>
802 return lhs.d_data_p == rhs.d_data_p;
805template <
class VALUE>
816template <
class VALUE>
820 return lhs.d_data_p ==
rhs.d_end_p;
823template <
class VALUE>
827 return lhs.d_end_p ==
rhs.d_data_p;
830template <
class VALUE>
834 return lhs.d_data_p !=
rhs.d_end_p;
837template <
class VALUE>
841 return lhs.d_end_p !=
rhs.d_data_p;
851template <
class VALUE,
class ALLOCATOR,
class CONVERTER,
bool USE_SENTINEL>
852void TestValuesArray<VALUE, ALLOCATOR, CONVERTER, USE_SENTINEL>::initialize(
857 d_size = strlen(spec);
861 size_type numBytes =
static_cast<size_type
>(
862 d_size *
sizeof(VALUE) + 2 * (d_size + 1) *
sizeof(bool));
863 size_type numMaxAlignedType =
867 AllocatorType alignAlloc(d_allocator);
868 d_data_p =
reinterpret_cast<VALUE *
>(AllocatorTraits::allocate(
869 alignAlloc, numMaxAlignedType));
871 d_dereferenceable_p =
reinterpret_cast<bool *
>(d_data_p + d_size);
872 d_validIterator_p = d_dereferenceable_p + d_size + 1;
874 for (
int i = 0;
'\0' != spec[i]; ++i) {
875 CONVERTER::createInplace(d_data_p + i, spec[i], d_allocator);
878 memset(d_dereferenceable_p,
true, d_size *
sizeof(
bool));
879 d_dereferenceable_p[d_size] =
false;
880 memset(d_validIterator_p,
true, (d_size + 1) *
sizeof(
bool));
883template <
class VALUE,
class ALLOCATOR,
class CONVERTER,
bool USE_SENTINEL>
892 d_dereferenceable_p + d_size,
893 d_validIterator_p + d_size);
896template <
class VALUE,
class ALLOCATOR,
class CONVERTER,
bool USE_SENTINEL>
906template <
class VALUE,
class ALLOCATOR,
class CONVERTER,
bool USE_SENTINEL>
915 d_dereferenceable_p + d_size,
916 d_validIterator_p + d_size);
919template <
class VALUE,
class ALLOCATOR,
class CONVERTER,
bool USE_SENTINEL>
930template <
class VALUE,
class ALLOCATOR,
class CONVERTER,
bool USE_SENTINEL>
932: d_allocator(&
bslma::MallocFreeAllocator::singleton())
934 static const char DEFAULT_SPEC[] =
935 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
937 initialize(DEFAULT_SPEC);
940template <
class VALUE,
class ALLOCATOR,
class CONVERTER,
bool USE_SENTINEL>
942 ALLOCATOR basicAllocator)
943: d_allocator(basicAllocator)
945 static const char DEFAULT_SPEC[] =
946 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
948 initialize(DEFAULT_SPEC);
951template <
class VALUE,
class ALLOCATOR,
class CONVERTER,
bool USE_SENTINEL>
955: d_allocator(&
bslma::MallocFreeAllocator::singleton())
960template <
class VALUE,
class ALLOCATOR,
class CONVERTER,
bool USE_SENTINEL>
964 ALLOCATOR basicAllocator)
965: d_allocator(basicAllocator)
970template <
class VALUE,
class ALLOCATOR,
class CONVERTER,
bool USE_SENTINEL>
973 for (
size_t i = 0; i < d_size; ++i) {
977 size_type numBytes =
static_cast<size_type
>(
978 d_size *
sizeof(VALUE) + 2 * (d_size + 1) *
sizeof(bool));
979 size_type numMaxAlignedType =
983 AllocatorType alignAlloc(d_allocator);
984 AllocatorTraits::deallocate(
987 reinterpret_cast<void *
>(d_data_p)),
995template <
class VALUE,
class ALLOCATOR,
class CONVERTER,
bool USE_SENTINEL>
1003 d_dereferenceable_p,
1007template <
class VALUE,
class ALLOCATOR,
class CONVERTER,
bool USE_SENTINEL>
1016template <
class VALUE,
class ALLOCATOR,
class CONVERTER,
bool USE_SENTINEL>
1027 d_dereferenceable_p + position,
1028 d_validIterator_p + position);
1031template <
class VALUE,
class ALLOCATOR,
class CONVERTER,
bool USE_SENTINEL>
1035 memset(d_dereferenceable_p, 1, d_size *
sizeof(
bool));
1036 d_dereferenceable_p[d_size] =
false;
1037 memset(d_validIterator_p, 1, (d_size + 1) *
sizeof(
bool));
1042template <
class VALUE,
class ALLOCATOR,
class CONVERTER,
bool USE_SENTINEL>
1050 d_dereferenceable_p,
1054template <
class VALUE,
class ALLOCATOR,
class CONVERTER,
bool USE_SENTINEL>
1063template <
class VALUE,
class ALLOCATOR,
class CONVERTER,
bool USE_SENTINEL>
1071template <
class VALUE,
class ALLOCATOR,
class CONVERTER,
bool USE_SENTINEL>
1078 return data()[index];
1081template <
class VALUE,
class ALLOCATOR,
class CONVERTER,
bool USE_SENTINEL>
1092template <
class VALUE,
class ALLOCATOR>
1097 ALLOCATOR allocator)
1106template <
class VALUE>
1115template <
class VALUE>
Definition bslma_bslallocator.h:588
Definition bsltf_testvaluesarray.h:251
TestValuesArrayIterator()
Definition bsltf_testvaluesarray.h:656
TestValuesArrayIterator & operator=(const TestValuesArrayIterator &other)
Definition bsltf_testvaluesarray.h:698
friend bool operator!=(const TestValuesArrayIterator< OTHER_VALUE > &, const TestValuesArraySentinel< OTHER_VALUE > &)
TestValuesArrayIterator & operator++()
Definition bsltf_testvaluesarray.h:712
VALUE value_type
Definition bsltf_testvaluesarray.h:295
friend bool operator==(const TestValuesArrayIterator< OTHER_VALUE > &, const TestValuesArraySentinel< OTHER_VALUE > &)
const VALUE * pointer
Definition bsltf_testvaluesarray.h:297
friend bool operator!=(const TestValuesArraySentinel< OTHER_VALUE > &, const TestValuesArrayIterator< OTHER_VALUE > &)
friend bool operator==(const TestValuesArrayIterator< OTHER_VALUE > &, const TestValuesArrayIterator< OTHER_VALUE > &)
ptrdiff_t difference_type
Definition bsltf_testvaluesarray.h:296
std::input_iterator_tag iterator_category
Definition bsltf_testvaluesarray.h:294
const VALUE * operator->() const
Definition bsltf_testvaluesarray.h:752
friend bool operator==(const TestValuesArraySentinel< OTHER_VALUE > &, const TestValuesArrayIterator< OTHER_VALUE > &)
const VALUE & operator*() const
Definition bsltf_testvaluesarray.h:741
const VALUE * address() const
Return the position (address) referenced by this iterator.
Definition bsltf_testvaluesarray.h:762
friend bool operator!=(const TestValuesArrayIterator< OTHER_VALUE > &, const TestValuesArrayIterator< OTHER_VALUE > &)
const VALUE & reference
Standard iterator defined types [24.4.2].
Definition bsltf_testvaluesarray.h:300
Definition bsltf_testvaluesarray.h:389
friend bool operator!=(const TestValuesArrayIterator< OTHER_VALUE > &, const TestValuesArraySentinel< OTHER_VALUE > &)
const VALUE * address() const
Return the position (address) referenced by this sentinel.
Definition bsltf_testvaluesarray.h:786
friend bool operator==(const TestValuesArrayIterator< OTHER_VALUE > &, const TestValuesArraySentinel< OTHER_VALUE > &)
TestValuesArraySentinel()
Definition bsltf_testvaluesarray.h:773
friend bool operator!=(const TestValuesArraySentinel< OTHER_VALUE > &, const TestValuesArrayIterator< OTHER_VALUE > &)
friend bool operator==(const TestValuesArraySentinel< OTHER_VALUE > &, const TestValuesArrayIterator< OTHER_VALUE > &)
Definition bsltf_testvaluesarray.h:625
const VALUE & operator*() const
Definition bsltf_testvaluesarray.h:1117
TestValuesArray_PostIncrementPtr(const VALUE *ptr)
Definition bsltf_testvaluesarray.h:1109
Definition bsltf_testvaluesarray.h:467
TestValuesArrayIterator< VALUE > iterator
Iterator/Sentinel for this container.
Definition bsltf_testvaluesarray.h:507
TestValuesArraySentinel< const VALUE > const_sentinel
Definition bsltf_testvaluesarray.h:510
iterator index(size_t position)
Definition bsltf_testvaluesarray.h:1020
const VALUE & operator[](size_t index) const
Definition bsltf_testvaluesarray.h:1074
bsl::conditional< USE_SENTINEL, const_sentinel, const_iterator >::type ConstEndReturnType
Definition bsltf_testvaluesarray.h:516
TestValuesArraySentinel< VALUE > sentinel
Definition bsltf_testvaluesarray.h:508
void resetIterators()
Make all iterators dereferenceable and comparable again.
Definition bsltf_testvaluesarray.h:1033
TestValuesArrayIterator< const VALUE > const_iterator
Definition bsltf_testvaluesarray.h:509
bsl::conditional< USE_SENTINEL, sentinel, iterator >::type EndReturnType
Definition bsltf_testvaluesarray.h:513
sentinel privateEnd(BSLMF_TYPEIDENTITY_T(sentinel))
Definition bsltf_testvaluesarray.h:901
const VALUE * data() const
Definition bsltf_testvaluesarray.h:1066
~TestValuesArray()
Destroy this container and all contained elements.
Definition bsltf_testvaluesarray.h:971
EndReturnType end()
Definition bsltf_testvaluesarray.h:1011
iterator begin()
Definition bsltf_testvaluesarray.h:999
size_t size() const
Return number of elements in this container.
Definition bsltf_testvaluesarray.h:1083
TestValuesArray()
Definition bsltf_testvaluesarray.h:931
#define BSLMF_TYPEIDENTITY_T(...)
Definition bslmf_typeidentity.h:256
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1917
#define BSLS_ASSERT_OPT(X)
Definition bsls_assert.h:2045
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
ALLOCATOR & lhs
Definition bslstl_string.h:3917
Definition baljsn_encoder_testtypes.h:76
Definition bsltf_allocargumenttype.h:92
bool operator!=(const AllocBitwiseMoveableTestType &lhs, const AllocBitwiseMoveableTestType &rhs)
bool operator==(const AllocBitwiseMoveableTestType &lhs, const AllocBitwiseMoveableTestType &rhs)
Definition bslma_allocatortraits.h:1089
static void destroy(ALLOCATOR_TYPE &basicAllocator, ELEMENT_TYPE *elementAddr)
Definition bslma_allocatortraits.h:1549
Definition bslmf_conditional.h:123
Definition bslmf_integralconstant.h:261
AlignmentToType< BSLS_MAX_ALIGNMENT >::Type MaxAlignedType
Definition bsls_alignmentutil.h:307
@ BSLS_MAX_ALIGNMENT
Definition bsls_alignmentutil.h:300
static void emplace(TYPE *address, int identifier, ALLOCATOR allocator)
Definition bsltf_templatetestfacility.h:1223
Definition bsltf_testvaluesarray.h:602
static void createInplace(VALUE *objPtr, char value, ALLOCATOR allocator)
Definition bsltf_testvaluesarray.h:1094