BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsltf_testvaluesarray.h
Go to the documentation of this file.
1/// @file bsltf_testvaluesarray.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bsltf_testvaluesarray.h -*-C++-*-
8#ifndef INCLUDED_BSLTF_TESTVALUESARRAY
9#define INCLUDED_BSLTF_TESTVALUESARRAY
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bsltf_testvaluesarray bsltf_testvaluesarray
15/// @brief Provide a container for values used for testing.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bsltf
19/// @{
20/// @addtogroup bsltf_testvaluesarray
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bsltf_testvaluesarray-purpose"> Purpose</a>
25/// * <a href="#bsltf_testvaluesarray-classes"> Classes </a>
26/// * <a href="#bsltf_testvaluesarray-description"> Description </a>
27/// * <a href="#bsltf_testvaluesarray-iterator"> Iterator </a>
28/// * <a href="#bsltf_testvaluesarray-thread-safety"> Thread Safety </a>
29/// * <a href="#bsltf_testvaluesarray-usage"> Usage </a>
30/// * <a href="#bsltf_testvaluesarray-example-1-testing-a-simple-template-function"> Example 1: Testing a Simple Template Function </a>
31///
32/// # Purpose {#bsltf_testvaluesarray-purpose}
33/// Provide a container for values used for testing.
34///
35/// # Classes {#bsltf_testvaluesarray-classes}
36///
37/// - bsltf::TestValuesArray: container for values used for testing
38/// - bsltf::TestValuesArrayIterator: iterator for the container
39///
40/// @see bsltf_templatetestfacility
41///
42/// # Description {#bsltf_testvaluesarray-description}
43/// This component defines a class `bsltf::TestValuesArray`
44/// providing a uniform interface for creating and accessing a sequence of test
45/// values of a type that has a copy constructor, and may or may not have a
46/// default constructor.
47///
48/// This component also defines an iterator class
49/// `bsltf::TestValuesArrayIterator` providing access to elements in a
50/// `TestValuesArray` object. `TestValuesArrayIterator` is designed to
51/// satisfies the minimal requirement of an input iterator as defined by the
52/// C++11 standard [24.2.3]. It uses the `BSLS_ASSERT` macro to detect
53/// undefined behavior.
54///
55/// The sequence described by this container is an input-range, that may be
56/// traversed exactly once. Once an iterator is incremented, any other iterator
57/// at the same position in the sequence is invalidated. The `TestValuesArray`
58/// object provides a `resetIterators` method that restores the ability to
59/// iterate the container.
60///
61/// ## Iterator {#bsltf_testvaluesarray-iterator}
62///
63///
64/// The requirements of the input iterators as defined by the C++11 standard may
65/// not be as tight as the users of the input iterators expected. Incorrect
66/// assumptions about the properties of the input iterator may result in
67/// undefined behavior. `TestValuesArrayIterator` is designed to detect
68/// possible incorrect usages. Specifically, `TestValuesArrayIterator` put
69/// restriction on when it can be dereferenced or compared. A
70/// `TestValuesArrayIterator` is considered to be *dereferenceable* if it
71/// satisfies all of the following:
72///
73/// 1. The iterator refers to a valid element (not `end`).
74/// 2. The iterator has not been dereferenced. (*)
75/// 3. The iterator is not a copy of another iterator of which `operator++`
76/// have been invoked. (see [table 107] of the C++11 standard)
77///
78/// *note: An input iterator may not be dereferenced more than once is a common
79/// requirement of a container method that takes input iterators as arguments.
80/// Other standard algorithms may allow the iterator to be dereferenced more
81/// than once, in which case, `TestValuesArrayIterator` is not suitable to be
82/// used to with those algorithms.
83///
84/// `TestValuesArrayIterator` is comparable if the iterator is not a copy of
85/// another iterator of which `operator++` have been invoked.
86///
87/// ## Thread Safety {#bsltf_testvaluesarray-thread-safety}
88///
89///
90/// This component is *not* thread-safe, by any definition of the term, and
91/// should not be used in test scenarios concerned with concurrent code.
92///
93/// ## Usage {#bsltf_testvaluesarray-usage}
94///
95///
96/// This section illustrates intended use of this component.
97///
98/// ### Example 1: Testing a Simple Template Function {#bsltf_testvaluesarray-example-1-testing-a-simple-template-function}
99///
100///
101/// Suppose that we have a function that we would like to test. This function
102/// take in a range defined by two input iterators and returns the largest value
103/// in that range.
104///
105/// First, we define the function we would like to test:
106/// @code
107/// template <class VALUE, class INPUT_ITERATOR>
108/// VALUE myMaxValue(INPUT_ITERATOR first, INPUT_ITERATOR last)
109/// // Return the largest value referred to by the iterators in the range
110/// // beginning at the specified 'first' and up to, but not including, the
111/// // specified 'last'. The behavior is undefined unless [first, last)
112/// // specifies a valid range and 'first != last'.
113/// {
114/// assert(first != last);
115///
116/// VALUE largestValue(*first);
117/// ++first;
118/// for(;first != last; ++first) {
119/// // Store in temporary variable to avoid dereferencing twice.
120///
121/// const VALUE& temp = *first;
122/// if (largestValue < temp) {
123/// largestValue = temp;
124/// }
125/// }
126/// return largestValue;
127/// }
128/// @endcode
129/// Next, we implement a test function `runTest` that allows the function to be
130/// tested with different types:
131/// @code
132/// template <class VALUE>
133/// void runTest()
134/// // Test driver.
135/// {
136/// @endcode
137/// Then, we define a set of test values and expected results:
138/// @code
139/// struct {
140/// const char *d_spec;
141/// const char d_result;
142/// } DATA[] = {
143/// { "A", 'A' },
144/// { "ABC", 'C' },
145/// { "ADCB", 'D' },
146/// { "EDCBA", 'E' }
147/// };
148/// const size_t NUM_DATA = sizeof DATA / sizeof *DATA;
149/// @endcode
150/// Now, for each set of test values, verify that the function return the
151/// expected result.
152/// @code
153/// for (size_t i = 0; i < NUM_DATA; ++i) {
154/// const char *const SPEC = DATA[i].d_spec;
155/// const VALUE EXP =
156/// bsltf::TemplateTestFacility::create<VALUE>(DATA[i].d_result);
157///
158/// bsltf::TestValuesArray<VALUE> values(SPEC);
159/// assert(EXP == myMaxValue<VALUE>(values.begin(), values.end()));
160/// }
161/// }
162/// @endcode
163/// Finally, we invoke the test function to verify our function is implemented
164/// correctly. The test function to run without triggering the `assert`
165/// statement:
166/// @code
167/// runTest<char>();
168/// @endcode
169/// @}
170/** @} */
171/** @} */
172
173/** @addtogroup bsl
174 * @{
175 */
176/** @addtogroup bsltf
177 * @{
178 */
179/** @addtogroup bsltf_testvaluesarray
180 * @{
181 */
182
183#include <bslscm_version.h>
184
186
187#include <bslma_bslallocator.h>
188
189#include <bsls_alignmentutil.h>
190
191#include <iterator>
192#include <stddef.h>
193#include <string.h>
194
195#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
196#include <bsls_nativestd.h>
197#endif // BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
198
199
200
201namespace bsltf {
202
203template <class VALUE, class ALLOCATOR>
204struct TestValuesArray_DefaultConverter;
205
206template <class VALUE>
207class TestValuesArray_PostIncrementPtr;
208
209 // =============================
210 // class TestValuesArrayIterator
211 // =============================
212
213/// This class provide a STL-conforming input iterator over values used for
214/// testing (see section [24.2.3 input.iterators] of the C++11 standard. A
215/// `TestValuesArrayIterator` provide access to elements of parameterized
216/// type `VALUE`. An iterator is considered dereferenceable all of the
217/// following are satisfied:
218/// 1. The iterator refers to a valid element (not `end`).
219/// 2. The iterator has not been dereferenced.
220/// 3. The iterator is not a copy of another iterator of which `operator++`
221/// have been invoked.
222/// An iterator is comparable if the iterator is not a copy of another
223/// iterator of which `operator++` have been invoked.
224///
225/// This class is *not* thread-safe: different iterator objects manipulate
226/// shared state without synchronization. This is rarely a concern for the
227/// test scenarios supported by this component.
228///
229/// See @ref bsltf_testvaluesarray
230template <class VALUE>
232
233 // DATA
234 const VALUE *d_data_p; // pointer to array of values (held,
235 // not owned)
236
237 const VALUE *d_end_p; // end pointer (held, not owned)
238
239 bool *d_dereferenceable_p; // indicate if dereferenceable (held,
240 // not owned)
241
242 bool *d_isValid_p; // indicate not yet invalidated (held,
243 // not owned)
244
245 private:
246 // FRIENDS
247 template <class OTHER_VALUE>
250
251 template <class OTHER_VALUE>
254
255 public:
256 // TYPES
257 typedef std::input_iterator_tag iterator_category;
258 typedef VALUE value_type;
259 typedef ptrdiff_t difference_type;
260 typedef const VALUE *pointer;
261
262 /// Standard iterator defined types [24.4.2].
263 typedef const VALUE& reference;
264
265 public:
266 // CREATORS
267
268 /// Create an iterator referring to the specified `object` for a
269 /// container with the specified `end`, with two arrays of boolean
270 /// referred to by the specified `dereferenceable` and `isValid` to
271 /// indicate whether this iterator and its subsequent values until
272 /// `end` is allowed to be dereferenced and is not yet invalidated
273 /// respectively.
274 TestValuesArrayIterator(const VALUE *object,
275 const VALUE *end,
276 bool *dereferenceable,
277 bool *isValid);
278
279 /// Create an iterator having the same value as the specified `original`
280 /// object. The behavior is undefined unless `original` is valid.
282
283 // MANIPULATORS
284
285 /// Assign to this object the value of the specified `other` object.
286 /// The behavior is undefined unless `other` is valid.
288
289 /// Move this iterator to the next element in the container. Any copies
290 /// of this iterator are no longer dereferenceable or comparable. The
291 /// behavior is undefined unless this iterator refers to a valid value
292 /// in the container.
294
295 /// Move this iterator to the next element in the container, and return
296 /// an object that can be dereferenced to refer to the same object that
297 /// this iterator initially points to. Any copies of this iterator are
298 /// no longer dereferenceable or comparable. The behavior is undefined
299 /// unless this iterator refers to a valid value in the container.
301
302 // ACCESSORS
303
304 /// Return the value referred to by this object. This object is no
305 /// longer dereferenceable after a call to this function. The behavior
306 /// is undefined unless this iterator is dereferenceable.
307 const VALUE& operator *() const;
308
309 /// Return the address of the element (of the template parameter
310 /// `VALUE`) at which this iterator is positioned. The behavior is
311 /// undefined unless this iterator dereferenceable.
312 const VALUE *operator->() const;
313};
314
315/// Return `true` if the specified `lhs` and the specified `rhs` refer to
316/// the same element, and `false` otherwise. The behavior is undefined
317/// unless `lhs` and `rhs` are comparable.
318template <class VALUE>
319bool operator==(const TestValuesArrayIterator<VALUE>& lhs,
321
322/// Return `true` if the specified `lhs` and the specified `rhs` do *not*
323/// refer to the same element, and `false` otherwise. The behavior is
324/// undefined unless `lhs` and `rhs` are comparable.
325template <class VALUE>
326bool operator!=(const TestValuesArrayIterator<VALUE>& lhs,
328
329 // =====================
330 // class TestValuesArray
331 // =====================
332
333/// This class provides a container to store values of the (template
334/// parameter) type `VALUE`, and also provides the iterators to access the
335/// values. The iterators are designed to conform to a standard input
336/// iterator, and report any misuse of the iterator.
337template <class VALUE,
338 class ALLOCATOR = bsl::allocator<VALUE>,
339 class CONVERTER =
342{
343
344 private:
345 // PRIVATE TYPES
348 typedef typename AllocatorTraits::allocator_type AllocatorType;
349 typedef typename AllocatorTraits::size_type size_type;
350
351 // DATA
352 ALLOCATOR d_allocator; // allocator (held, not owned)
353
354 VALUE *d_data_p; // pointer to memory storing the values
355 // (owned)
356
357 size_t d_size; // number of elements in this container
358
359 bool *d_dereferenceable_p; // pointer to an array to indicate if
360 // value is dereferenceable (owned)
361
362 bool *d_validIterator_p; // pointer to an array to indicate if
363 // value is comparable (owned)
364
365 // NOT IMPLEMENTED
366 TestValuesArray(const TestValuesArray&); // = delete
367 TestValuesArray& operator=(const TestValuesArray&); // = delete
368
369 // PRIVATE MANIPULATOR
370
371 /// Initialize this container, using the specified `spec` to populate
372 /// container with test values.
373 void initialize(const char *spec);
374
375 public:
376 // TYPES
377
378 /// Iterator for this container.
380
381 public:
382 // CREATORS
383
384 explicit TestValuesArray();
385 explicit TestValuesArray(ALLOCATOR basicAllocator);
386 explicit TestValuesArray(const char *spec);
387 /// Create a `TestValuesArray` object. Optionally, specify `spec` to
388 /// indicate the values this object should contain, where the values are
389 /// created by invoking the `bsltf::TemplateTestFacility::create` method
390 /// on each character of `spec`. If no `spec` is supplied, the object
391 /// will contain 52 distinct values of the (template parameter) type
392 /// `VALUE`. Optionally, specify `basicAllocator` used to supply
393 /// memory. If no allocator is supplied, a `bslma::MallocFree`
394 /// allocator is used to supply memory.
395 explicit TestValuesArray(const char *spec, ALLOCATOR basicAllocator);
396
397 /// Destroy this container and all contained elements.
399
400 // MANIPULATORS
401
402 /// Return an iterator providing non-modifiable access to the first
403 /// `VALUE` object in the sequence of `VALUE` objects maintained by this
404 /// container, or the `end` iterator if this container is empty.
405 iterator begin();
406
407 /// Return an iterator providing access to the past-the-end position in
408 /// the sequence of `VALUE` objects maintained by this container.
409 iterator end();
410
411 /// Return an iterator to the element at the specified `position`. The
412 /// behavior is undefined unless `position <= size()`.
413 iterator index(size_t position);
414
415 /// Make all iterators dereferenceable and comparable again.
416 void resetIterators();
417
418 // ACCESSORS
419
420 /// Return the address of the non-modifiable first element in this
421 /// container.
422 const VALUE *data() const;
423
424 /// Return a reference providing non-modifiable access to the element at
425 /// the specified `index`. The behavior is undefined unless
426 /// `0 < size() && index < size()`.
427 const VALUE& operator[](size_t index) const;
428
429 /// Return number of elements in this container.
430 size_t size() const;
431};
432
433 // ======================================
434 // class TestValuesArray_DefaultConverter
435 // ======================================
436
437/// This `struct` provides a namespace for an utility function,
438/// `createInplace`, that creates an object of the (template parameter) type
439/// `VALUE` from a character identifier.
440template <class VALUE, class ALLOCATOR>
442{
443 // CLASS METHODS
444
445 /// Create an object of the (template parameter) type `VALUE` at the
446 /// specified `objPtr` address whose state is unique for the specified
447 /// `value`. Use the specified `allocator` to supply memory. The
448 /// behavior is undefined unless `0 <= value && value < 128` and `VALUE`
449 /// is contained in the macro
450 /// `BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_ALL`.
451 static void createInplace(VALUE *objPtr, char value, ALLOCATOR allocator);
452};
453
454 // ======================================
455 // class TestValuesArray_PostIncrementPtr
456 // ======================================
457
458/// This class is a wrapper that encapsulates a reference, providing
459/// non-modifiable access to the element of `TestValuesArray` container.
460/// Object of this class is returned by post increment operator of
461/// TestValuesArray' container.
462template <class VALUE>
464{
465 private:
466 // DATA
467 const VALUE *d_data_p; // pointer to the value (not owned)
468
469 public:
470 // CREATORS
471
472 /// Create a `TestValuesArray_PostIncrementPtr` object having the value
473 /// of the specified `ptr`.
474 explicit TestValuesArray_PostIncrementPtr(const VALUE* ptr);
475
476 // ACCESSORS
477
478 /// Return a reference providing non-modifiable access to the object
479 /// referred to by this wrapper.
480 const VALUE& operator*() const;
481};
482
483// ============================================================================
484// INLINE DEFINITIONS
485// ============================================================================
486
487 // -----------------------------
488 // class TestValuesArrayIterator
489 // -----------------------------
490
491// CREATORS
492template <class VALUE>
493inline
495 const VALUE *object,
496 const VALUE *end,
497 bool *dereferenceable,
498 bool *isValid)
499: d_data_p(object)
500, d_end_p(end)
501, d_dereferenceable_p(dereferenceable)
502, d_isValid_p(isValid)
503{
504 BSLS_ASSERT_SAFE(object);
505 BSLS_ASSERT_SAFE(end);
506 BSLS_ASSERT_SAFE(dereferenceable);
507 BSLS_ASSERT_SAFE(isValid);
508 BSLS_ASSERT_SAFE(*isValid);
509}
510
511template <class VALUE>
512inline
514 const TestValuesArrayIterator& original)
515: d_data_p(original.d_data_p)
516, d_end_p(original.d_end_p)
517, d_dereferenceable_p(original.d_dereferenceable_p)
518, d_isValid_p(original.d_isValid_p)
519{
520 BSLS_ASSERT_OPT(*original.d_isValid_p);
521}
522
523// MANIPULATORS
524template <class VALUE>
527{
528 BSLS_ASSERT_OPT(*other.d_isValid_p);
529
530 d_data_p = other.d_data_p;
531 d_end_p = other.d_end_p;
532 d_dereferenceable_p = other.d_dereferenceable_p;
533 d_isValid_p = other.d_isValid_p;
534
535 return *this;
536}
537
538template <class VALUE>
541{
542 BSLS_ASSERT_OPT(d_data_p != d_end_p);
543 BSLS_ASSERT_OPT(*d_isValid_p);
544
545 *d_dereferenceable_p = false;
546 *d_isValid_p = false;
547
548 ++d_data_p;
549 ++d_dereferenceable_p;
550 ++d_isValid_p;
551 return *this;
552}
553
554template <class VALUE>
557{
558 BSLS_ASSERT_OPT(*d_isValid_p);
559 BSLS_ASSERT_OPT(d_data_p != d_end_p);
560
562 this->operator++();
563 return result;
564}
565
566// ACCESSORS
567template <class VALUE>
568inline
570{
571 BSLS_ASSERT_OPT(*d_isValid_p);
572 BSLS_ASSERT_OPT(*d_dereferenceable_p);
573
574 *d_dereferenceable_p = false;
575 return *d_data_p;
576}
577
578template <class VALUE>
579inline
581{
582 BSLS_ASSERT_OPT(*d_isValid_p);
583 BSLS_ASSERT_OPT(*d_dereferenceable_p);
584
585 *d_dereferenceable_p = false;
586 return d_data_p;
587}
588
589} // close package namespace
590
591// FREE OPERATORS
592template <class VALUE>
593inline
596{
597 BSLS_ASSERT_OPT(*lhs.d_isValid_p);
598 BSLS_ASSERT_OPT(*rhs.d_isValid_p);
599
600 return lhs.d_data_p == rhs.d_data_p;
601}
602
603template <class VALUE>
604inline
607{
608 BSLS_ASSERT_OPT(*lhs.d_isValid_p);
609 BSLS_ASSERT_OPT(*rhs.d_isValid_p);
610
611 return !(lhs == rhs);
612}
613
614namespace bsltf {
615 // ---------------------
616 // class TestValuesArray
617 // ---------------------
618
619// CREATORS
620template <class VALUE, class ALLOCATOR, class CONVERTER>
622: d_allocator(&bslma::MallocFreeAllocator::singleton())
623{
624 static const char DEFAULT_SPEC[] =
625 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
626
627 initialize(DEFAULT_SPEC);
628}
629
630template <class VALUE, class ALLOCATOR, class CONVERTER>
632 ALLOCATOR basicAllocator)
633: d_allocator(basicAllocator)
634{
635 static const char DEFAULT_SPEC[] =
636 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
637
638 initialize(DEFAULT_SPEC);
639}
640
641template <class VALUE, class ALLOCATOR, class CONVERTER>
642inline
644: d_allocator(&bslma::MallocFreeAllocator::singleton())
645{
646 initialize(spec);
647}
648
649template <class VALUE, class ALLOCATOR, class CONVERTER>
650inline
652 const char *spec,
653 ALLOCATOR basicAllocator)
654: d_allocator(basicAllocator)
655{
656 initialize(spec);
657}
658
659template <class VALUE, class ALLOCATOR, class CONVERTER>
661{
662 for (size_t i = 0; i < d_size; ++i) {
663 bsl::allocator_traits<ALLOCATOR>::destroy(d_allocator, d_data_p + i);
664 }
665
666 size_type numBytes = static_cast<size_type>(
667 d_size * sizeof(VALUE) + 2 * (d_size + 1) * sizeof(bool));
668 size_type numMaxAlignedType =
671
672 AllocatorType alignAlloc(d_allocator);
673 AllocatorTraits::deallocate(
674 alignAlloc,
675 reinterpret_cast<bsls::AlignmentUtil::MaxAlignedType *>(
676 reinterpret_cast<void *>(d_data_p)),
677 numMaxAlignedType);
678 // The redundant cast to 'void *' persuades gcc/Solaris that there are
679 // no alignment issues to warn about.
680}
681
682// PRIVATE MANIPULATORS
683template <class VALUE, class ALLOCATOR, class CONVERTER>
685{
686 BSLS_ASSERT_SAFE(spec);
687
688 d_size = strlen(spec);
689
690 // Allocate all memory in one go.
691
692 size_type numBytes = static_cast<size_type>(
693 d_size * sizeof(VALUE) + 2 * (d_size + 1) * sizeof(bool));
694 size_type numMaxAlignedType =
697
698 AllocatorType alignAlloc(d_allocator);
699 d_data_p = reinterpret_cast<VALUE *>(AllocatorTraits::allocate(
700 alignAlloc, numMaxAlignedType));
701
702 d_dereferenceable_p = reinterpret_cast<bool *>(d_data_p + d_size);
703 d_validIterator_p = d_dereferenceable_p + d_size + 1;
704
705 for (int i = 0; '\0' != spec[i]; ++i) {
706 CONVERTER::createInplace(d_data_p + i, spec[i], d_allocator);
707 }
708
709 memset(d_dereferenceable_p, true, d_size * sizeof(bool));
710 d_dereferenceable_p[d_size] = false; // 'end' is never dereferenceable
711 memset(d_validIterator_p, true, (d_size + 1) * sizeof(bool));
712}
713
714// MANIPULATORS
715template <class VALUE, class ALLOCATOR, class CONVERTER>
716inline
719{
720 return iterator(data(),
721 data() + d_size,
722 d_dereferenceable_p,
723 d_validIterator_p);
724}
725
726template <class VALUE, class ALLOCATOR, class CONVERTER>
727inline
730{
731 return iterator(data() + d_size,
732 data() + d_size,
733 d_dereferenceable_p + d_size,
734 d_validIterator_p + d_size);
735}
736
737template <class VALUE, class ALLOCATOR, class CONVERTER>
738inline
741{
742 BSLS_ASSERT_SAFE(position <= size());
743
744 return iterator(data() + position,
745 data() + d_size,
746 d_dereferenceable_p + position,
747 d_validIterator_p + position);
748}
749
750template <class VALUE, class ALLOCATOR, class CONVERTER>
752{
753 memset(d_dereferenceable_p, 1, d_size * sizeof(bool));
754 d_dereferenceable_p[d_size] = false;
755 memset(d_validIterator_p, 1, (d_size + 1) * sizeof(bool));
756}
757
758// ACCESSORS
759template <class VALUE, class ALLOCATOR, class CONVERTER>
760inline
762{
763 return d_data_p;
764}
765
766template <class VALUE, class ALLOCATOR, class CONVERTER>
767inline
769operator[](size_t index) const
770{
771 BSLS_ASSERT_SAFE(0 < size() && index < size());
772
773 return data()[index];
774}
775
776template <class VALUE, class ALLOCATOR, class CONVERTER>
777inline
779{
780 return d_size;
781}
782
783 // --------------------------------------
784 // class TestValuesArray_DefaultConverter
785 // --------------------------------------
786
787template <class VALUE, class ALLOCATOR>
788inline
790 VALUE *objPtr,
791 char value,
792 ALLOCATOR allocator)
793{
794 bsltf::TemplateTestFacility::emplace(objPtr, value, allocator);
795}
796
797 // --------------------------------------
798 // class TestValuesArray_PostIncrementPtr
799 // --------------------------------------
800
801template <class VALUE>
802inline
804TestValuesArray_PostIncrementPtr(const VALUE* ptr)
805: d_data_p(ptr)
806{
807 BSLS_ASSERT_SAFE(ptr);
808}
809
810template <class VALUE>
811inline
813{
814 return *d_data_p;
815}
816
817} // close package namespace
818
819
820#endif
821
822// ----------------------------------------------------------------------------
823// Copyright 2013 Bloomberg Finance L.P.
824//
825// Licensed under the Apache License, Version 2.0 (the "License");
826// you may not use this file except in compliance with the License.
827// You may obtain a copy of the License at
828//
829// http://www.apache.org/licenses/LICENSE-2.0
830//
831// Unless required by applicable law or agreed to in writing, software
832// distributed under the License is distributed on an "AS IS" BASIS,
833// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
834// See the License for the specific language governing permissions and
835// limitations under the License.
836// ----------------------------- END-OF-FILE ----------------------------------
837
838/** @} */
839/** @} */
840/** @} */
Definition bslma_bslallocator.h:580
Definition bsltf_testvaluesarray.h:231
TestValuesArrayIterator & operator=(const TestValuesArrayIterator &other)
Definition bsltf_testvaluesarray.h:526
TestValuesArrayIterator & operator++()
Definition bsltf_testvaluesarray.h:540
VALUE value_type
Definition bsltf_testvaluesarray.h:258
const VALUE * pointer
Definition bsltf_testvaluesarray.h:260
friend bool operator==(const TestValuesArrayIterator< OTHER_VALUE > &, const TestValuesArrayIterator< OTHER_VALUE > &)
ptrdiff_t difference_type
Definition bsltf_testvaluesarray.h:259
std::input_iterator_tag iterator_category
Definition bsltf_testvaluesarray.h:257
const VALUE * operator->() const
Definition bsltf_testvaluesarray.h:580
const VALUE & operator*() const
Definition bsltf_testvaluesarray.h:569
TestValuesArrayIterator(const VALUE *object, const VALUE *end, bool *dereferenceable, bool *isValid)
Definition bsltf_testvaluesarray.h:494
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:263
Definition bsltf_testvaluesarray.h:464
const VALUE & operator*() const
Definition bsltf_testvaluesarray.h:812
TestValuesArray_PostIncrementPtr(const VALUE *ptr)
Definition bsltf_testvaluesarray.h:804
Definition bsltf_testvaluesarray.h:342
void resetIterators()
Make all iterators dereferenceable and comparable again.
Definition bsltf_testvaluesarray.h:751
TestValuesArrayIterator< VALUE > iterator
Iterator for this container.
Definition bsltf_testvaluesarray.h:379
const VALUE * data() const
Definition bsltf_testvaluesarray.h:761
size_t size() const
Return number of elements in this container.
Definition bsltf_testvaluesarray.h:778
iterator index(size_t position)
Definition bsltf_testvaluesarray.h:740
iterator end()
Definition bsltf_testvaluesarray.h:729
~TestValuesArray()
Destroy this container and all contained elements.
Definition bsltf_testvaluesarray.h:660
const VALUE & operator[](size_t index) const
Definition bsltf_testvaluesarray.h:769
TestValuesArray()
Definition bsltf_testvaluesarray.h:621
iterator begin()
Definition bsltf_testvaluesarray.h:718
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_ASSERT_OPT(X)
Definition bsls_assert.h:1856
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition balxml_encoderoptions.h:68
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:1061
static void destroy(ALLOCATOR_TYPE &basicAllocator, ELEMENT_TYPE *elementAddr)
Definition bslma_allocatortraits.h:1494
AlignmentToType< BSLS_MAX_ALIGNMENT >::Type MaxAlignedType
Definition bsls_alignmentutil.h:282
@ BSLS_MAX_ALIGNMENT
Definition bsls_alignmentutil.h:275
static void emplace(TYPE *address, int identifier, ALLOCATOR allocator)
Definition bsltf_templatetestfacility.h:1199
Definition bsltf_testvaluesarray.h:442
static void createInplace(VALUE *objPtr, char value, ALLOCATOR allocator)
Definition bsltf_testvaluesarray.h:789