BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsltf_templatetestfacility.h
Go to the documentation of this file.
1/// @file bsltf_templatetestfacility.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bsltf_templatetestfacility.h -*-C++-*-
8#ifndef INCLUDED_BSLTF_TEMPLATETESTFACILITY
9#define INCLUDED_BSLTF_TEMPLATETESTFACILITY
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bsltf_templatetestfacility bsltf_templatetestfacility
15/// @brief Provide utilities to help with testing templates.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bsltf
19/// @{
20/// @addtogroup bsltf_templatetestfacility
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bsltf_templatetestfacility-purpose"> Purpose</a>
25/// * <a href="#bsltf_templatetestfacility-classes"> Classes </a>
26/// * <a href="#bsltf_templatetestfacility-macros"> Macros </a>
27/// * <a href="#bsltf_templatetestfacility-description"> Description </a>
28/// * <a href="#bsltf_templatetestfacility-templatetestfacility"> TemplateTestFacility </a>
29/// * <a href="#bsltf_templatetestfacility-macros-and-test-types"> Macros and Test Types </a>
30/// * <a href="#bsltf_templatetestfacility-usage"> Usage </a>
31/// * <a href="#bsltf_templatetestfacility-example-1-using-the-bsltf_templatetestfacility_run_each_type-macro"> Example 1: Using the BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE Macro </a>
32/// * <a href="#bsltf_templatetestfacility-example-2-writing-a-type-independent-test-driver"> Example 2: Writing a Type Independent Test Driver </a>
33///
34/// # Purpose {#bsltf_templatetestfacility-purpose}
35/// Provide utilities to help with testing templates.
36///
37/// # Classes {#bsltf_templatetestfacility-classes}
38///
39/// - bsltf::TemplateTestFacility: namespace for template-testing utilities
40///
41/// # Macros {#bsltf_templatetestfacility-macros}
42///
43/// - BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE(CLASS, METHOD, TYPE...): run all
44/// - BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_PRIMITIVE: list of primitive types
45/// - BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_USER_DEFINED: list user types
46/// - BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_REGULAR: list of typical types
47/// - BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_AWKWARD: list of atypical types
48/// - BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_ALL: list all `bslmf` types
49///
50/// @see bsltf_simpletesttype, bslstl_map
51///
52/// # Description {#bsltf_templatetestfacility-description}
53/// When testing a container template having a type parameter, we
54/// need to ensure that the template supports its contractually specified
55/// categories of parameter types. The `bsltf` package provides a
56/// representative set of types intended for testing that can be used as
57/// template parameters for doing this kind of verification.
58///
59/// Creating a separate test for each category of types supported by a template
60/// would be cumbersome. Instead, writing a single templatized test is usually
61/// preferable. Unfortunately, different types often require different syntaxes
62/// for constructing an object and getting an object's value. This
63/// inconsistency makes writing generic code rather difficult.
64///
65/// This component provides a solution with a utility `struct`,
66/// `TemplateTestFacility`, that defines two class method templates, `create`
67/// and `getIdentifier`, that respectively have consistent syntaxes for creating
68/// objects and getting a integer value representing the state of objects of a
69/// parameterized type.
70///
71/// This component also provides a macro,
72/// `BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE`, that serves as a convenient way
73/// to instantiate and invoke a template (for testing) having a type parameter
74/// for a specified list of types. In addition, this component provides a set
75/// of macros referring to commonly useful lists of types intended for testing
76/// that can be used as arguments to `BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE`.
77///
78/// The utilities and macros provided by this component, along with the types
79/// defined in the `bsltf` package, are explained in more detail in the
80/// following sections.
81///
82/// ## TemplateTestFacility {#bsltf_templatetestfacility-templatetestfacility}
83///
84///
85/// The `TemplateTestFacility` `struct` provides the following static (class)
86/// method templates to construct objects and get the states of objects of a
87/// supported parameterized type (supported types are those types intended for
88/// testing defined in the `bsltf` package):
89///
90/// * `create`: Return an object of the parameterized `TYPE` whose value is
91/// uniquely associated with a specified integer identifier.
92///
93/// * `getIdentifier`: Return the integer identifier used to create a specified
94/// object of the parameterized `TYPE`.
95///
96/// ## Macros and Test Types {#bsltf_templatetestfacility-macros-and-test-types}
97///
98///
99/// The `BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE` macro instantiates a
100/// specified class template for a specified list of types and call a specified
101/// class method of each instantiation. The macro takes in arguments in the
102/// following order:
103///
104/// * The name of the class template to be instantiated
105/// * The name of the class method to be invoked
106/// * The names of the types for which the class template will be instantiated
107/// (up to 20)
108///
109/// This component also defines a set of macros, each providing a list of types,
110/// that can be used as the last argument to
111/// `BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE`. The following is a brief
112/// synopsis of these macros (note that all macros names have the
113/// `BSLTF_TEMPLATETESTFACILITY_` prefix, which is omitted for layout
114/// efficiency):
115///
116/// * `TEST_TYPES_PRIMITIVE`: list of primitive types
117/// * `TEST_TYPES_USER_DEFINED`: list of user-defined types
118/// * `TEST_TYPES_REGULAR`: list of typically used types
119/// * `TEST_TYPES_AWKWARD`: list of types with odd behaviors
120/// * `TEST_TYPES_ALL`: list of all of the types
121///
122/// The `BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_PRIMITIVE` macro refers to a
123/// representative set of primitive types that are useful for testing:
124/// @code
125/// Type Description
126/// ---- -----------
127/// signed char signed character
128///
129/// size_t signed integral type
130///
131/// TemplateTestFacility::ObjectPtr pointer to an object
132///
133/// TemplateTestFacility::FunctionPtr pointer to a function
134///
135/// TemplateTestFacility::MethodPtr pointer to a method
136/// @endcode
137/// The `BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_USER_DEFINED` macro refers to a
138/// representative set of user-defined types that are useful for testing (note
139/// that all types described here belong to the `bsltf` namespace, which is not
140/// explicitly qualified for layout efficiency):
141/// @code
142/// Type Description
143/// ---- -----------
144/// EnumeratedTestType::Enum an enumeration
145///
146/// UnionTestType a union
147///
148/// SimpleTestType class with no special traits defined
149///
150/// AllocTestType class that allocates memory, defines
151/// the 'bslma::UsesBslmaAllocator'
152/// trait, and ensures it is not bitwise
153/// moved
154///
155/// NonOptionalAllocTestType class that allocates memory, defines
156/// the 'bslma::UsesBslmaAllocator'
157/// trait, ensures it is not bitwise
158/// moved, and does not have default ctor.
159///
160/// MovableTestType class that has both move and copy
161/// semantics, and ensures it is not
162/// bitwise moved
163///
164/// MovableAllocTestType class that has both move and copy
165/// semantics, allocates memory, defines
166/// the 'bslma::UsesBslmaAllocator'
167/// trait, and ensures it is not bitwise
168/// moved
169///
170/// MoveOnlyAllocTestType class that has only move semantics,
171/// allocates memory, defines the
172/// 'bslma::UsesBslmaAllocator'
173/// trait, and ensures it is not bitwise
174/// moved
175///
176/// BitwiseCopyableTestType class that is bitwise-copyable and
177/// defines the
178/// 'bsl::is_trivially_copyable'
179/// trait
180///
181/// BitwiseMoveableTestType class that is bitwise-moveable and
182/// defines the
183/// 'bslmf::IsBitwiseMoveable'
184/// trait
185///
186/// AllocatingBitwiseMoveableTestType class that allocates memory, is
187/// bitwisemoveable, and defines the
188/// 'bslma::UsesBslmaAllocator'
189/// and 'bslmf::IsBitwiseMoveable'
190/// traits
191///
192/// NonTypicalOverloadsTestType class that defines and assert on
193/// invocation of certain
194/// non-typically-overloaded operators
195/// ('operator new', 'operator delete',
196/// 'operator&') to ensure that they are
197/// not called
198///
199/// EmplacableTestType class that takes <= 14 non-allocating
200/// arguments and is used to ensure that
201/// arguments are forwarded correctly
202/// from functions and methods taking
203/// variable number of arguments and their
204/// analagous in C++03 environments.
205///
206/// AllocEmplacableTestType class that takes up to 14 allocating
207/// arguments and is used to ensure that
208/// arguments are forwarded correctly
209/// from functions and methods taking
210/// variable number of arguments and their
211/// analagous in C++03 environments.
212/// @endcode
213///
214/// The `BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_REGULAR` macro refers to the
215/// union of the types provided by
216/// `BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_PRIMITIVE` and
217/// `BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_USER_DEFINED`. These types are
218/// designed to work within the regular operating conditions of a typical
219/// template. Typically, a test driver for a template instantiates its tests
220/// (using the `BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE` macro) for all of the
221/// types referred by `BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_REGULAR`.
222///
223/// The `BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_AWKWARD` macro refers to a set of
224/// types that have certain attributes that make them unlikely to work for all
225/// of the operations of a template. Typically, not all methods of a template
226/// are instantiable with these types, so these types are most often used
227/// independently in tests explicitly designed for a (single) type.
228/// @code
229/// Type Description
230/// ---- -----------
231/// NonAssignableTestType class having no assignment operator
232///
233/// NonCopyConstructibleTestType class having no copy constructor (Note
234/// that this class can not be created with
235/// 'TemplateTestFacility::create' because
236/// the class method returns the newly
237/// constructed object by value.)
238///
239/// NonDefaultConstructibleTestType class having no default constructor
240///
241/// NonEqualComparableTestType class having no equality-comparison
242/// operators
243/// @endcode
244/// The `BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_ALL` refers to all the test types
245/// provided in the `bsltf` package.
246///
247/// ## Usage {#bsltf_templatetestfacility-usage}
248///
249///
250/// This section illustrates intended use of this component.
251///
252/// ### Example 1: Using the BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE Macro {#bsltf_templatetestfacility-example-1-using-the-bsltf_templatetestfacility_run_each_type-macro}
253///
254///
255/// In this example, we demonstrate how to use
256/// `BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE` to call a class method of a
257/// template for a list of types.
258///
259/// First, we define a `struct` template `TestTemplate` taking in a
260/// parameterized `TYPE` that has a class method, `printTypeName`:
261/// @code
262/// template <class TYPE>
263/// struct TestTemplate {
264/// // This 'struct' provides a namespace for a simple test method.
265///
266/// // CLASS METHODS
267/// static void printTypeName();
268/// // Prints the name of the parameterized 'TYPE' to the console.
269/// };
270///
271/// template <>
272/// void TestTemplate<int>::printTypeName()
273/// {
274/// printf("int\n");
275/// }
276///
277/// template <>
278/// void TestTemplate<char>::printTypeName()
279/// {
280/// printf("char\n");
281/// }
282///
283/// template <>
284/// void TestTemplate<double>::printTypeName()
285/// {
286/// printf("double\n");
287/// }
288/// @endcode
289/// Now, we can instantiate the `TestTemplate` class for each of the types
290/// `int`, `char`, and `double`, and call the `printTypeName` class method of
291/// each instantiation using the `BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE`
292/// macro:
293/// @code
294/// BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE(TestTemplate,
295/// printTypeName,
296/// int, char, double);
297/// @endcode
298/// Finally, we observe the console output:
299/// @code
300/// int
301/// char
302/// double
303/// @endcode
304///
305/// ### Example 2: Writing a Type Independent Test Driver {#bsltf_templatetestfacility-example-2-writing-a-type-independent-test-driver}
306///
307///
308/// In this example, we demonstrate using the `TemplateTestFacility` `struct`
309/// and the macros provided by this component to test the default constructor
310/// and primary manipulator of a class template in the context of a typical
311/// BDE-style test driver. Note that a goal of the demonstrated test is to
312/// validate the class template with a broad range of types emulating those with
313/// which the template might be instantiated.
314///
315/// First, we define a simple class template, `MyNullableValue`, that we will
316/// later need to test:
317/// @code
318/// template <class TYPE>
319/// class MyNullableValue {
320/// // This (value-semantic) class template extends the parameterized
321/// // 'TYPE' to include the notion of a "null" value.
322///
323/// // DATA
324/// TYPE d_value; // non-null value
325/// bool d_nullFlag; // flag to indicate if the value is null
326///
327/// public:
328/// MyNullableValue()
329/// // Create a 'MyNullableValue' that initially has a value of null.
330/// : d_nullFlag(true)
331/// {
332/// }
333///
334/// bool isNull() const
335/// // Return 'true' if this object is null, and 'false' otherwise.
336/// {
337/// return d_nullFlag;
338/// }
339///
340/// void makeNull()
341/// // Set this object to the null value.
342/// {
343/// d_nullFlag = true;
344/// }
345///
346/// const TYPE& value() const {
347/// // Return a reference providing non-modifiable access to the
348/// // underlying object of the parameterized 'TYPE'. The behavior is
349/// // undefined if the object is null.
350/// return d_value;
351/// }
352///
353/// void makeValue(const TYPE& value)
354/// // Set the value of this object to be that of the specified 'value'
355/// // of the parameterized 'TYPE'.
356/// {
357/// d_nullFlag = false;
358/// d_value = value;
359/// }
360/// };
361/// @endcode
362/// Then, we define some aliases for the micros that will be used by the test
363/// driver:
364/// @code
365/// #define RUN_EACH_TYPE BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE
366/// #define TEST_TYPES_REGULAR BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_REGULAR
367/// @endcode
368/// Next, we define a `struct` template, `MyTestDriver`, that provides a
369/// namespace containing the test cases (here, only `testCase2` is defined for
370/// brevity) of the test driver:
371/// @code
372/// template <class TYPE>
373/// struct MyTestDriver {
374/// // This 'struct' provides a namespace for the class methods used to
375/// // implement the test driver.
376///
377/// // TYPES
378/// typedef MyNullableValue<TYPE> Obj;
379/// // This 'typedef' provides an alias to the type under testing.
380///
381/// static void testCase2();
382/// // Test primary manipulators.
383/// };
384/// @endcode
385/// Now, we define the implementation of `MyTestDriver::testCase2`:
386/// @code
387/// template <class TYPE>
388/// void MyTestDriver<TYPE>::testCase2()
389/// {
390/// // --------------------------------------------------------------------
391/// // DEFAULT CTOR, PRIMARY MANIPULATORS, AND DTOR
392/// // Ensure that we can use the default constructor to create an
393/// // object (having the default-constructed value), use the primary
394/// // manipulators to put that object into any state relevant for
395/// // thorough testing, and use the destructor to destroy it safely.
396/// //
397/// // Concerns:
398/// //: 1 An object created using the default constructor (with or without
399/// //: a supplied allocator) has the contractually specified value.
400/// //:
401/// //: 2 The 'makeValue' method sets the value of a object to any
402/// //: specified value.
403/// //:
404/// //: 3 The 'makeNull' method set the value of a object to null.
405/// //:
406/// //: 4 Objects of different values can coexist.
407/// //:
408/// //: 5 The destructor does not modify other objects.
409/// //
410/// // Plan:
411/// //: 1 Default-construct an object and use the (as yet unproven) salient
412/// //: attribute accessors to verify that the value of the object is the
413/// //: null value. (C-1)
414/// //:
415/// //: 2 Default-construct another object, and use the 'makeValue' method,
416/// //: to set the value of the object to a non-null value. Use the (as
417/// //: yet unproven) salient attribute accessors to verify that the new
418/// //: object has the expected value and the object created in P-1 still
419/// //: has the same value. (C-2, 4)
420/// //:
421/// //: 3 Using the loop-based approach, for each identifier in a range of
422/// //: integer identifiers:
423/// //:
424/// //: 1 Default-construct a modifiable object, 'mL', and use the (as
425/// //: yet unproven) salient attribute accessors to verify the value
426/// //: of the default constructed object is the null value. (C-1)
427/// //:
428/// //: 2 Create an object of the parameterized 'TYPE', 'LV', using the
429/// //: 'TemplateTestFacility::create' class method template,
430/// //: specifying the integer loop identifier.
431/// //:
432/// //: 3 Use the 'makeValue' method to set the value of 'mL' to 'LV'.
433/// //: Use the (as yet unproven) salient attribute accessors to verify
434/// //: 'mL' has the expected value. (C-2)
435/// //:
436/// //: 4 Invoke the 'makeNull' method of 'mL'. Use the attribute
437/// //: accessors to verify the value of the object is now null. (C-3)
438/// //:
439/// //: 4 Create an object in a nested block. Below the block, verify the
440/// //: objects created in P-1 and P-2 still have the same value. (C-5)
441/// //
442/// // Testing:
443/// // MyNullableValue();
444/// // ~MyNullableValue();
445/// // void makeNull();
446/// // void MakeValue(const TYPE& value);
447/// // --------------------------------------------------------------------
448///
449/// if (verbose)
450/// printf("\nDEFAULT CTOR, PRIMARY MANIPULATORS, AND DTOR"
451/// "\n============================================\n");
452///
453///
454/// if (verbose) printf("\nTesting default constructor.\n");
455///
456/// Obj mW; const Obj& W = mW;
457/// assert(true == W.isNull());
458///
459/// Obj mX; const Obj& X = mX;
460/// const TYPE XV = TemplateTestFacility::create<TYPE>(1);
461/// mX.makeValue(XV);
462/// assert(1 == TemplateTestFacility::getIdentifier<TYPE>(X.value()));
463///
464/// if (verbose) printf("\nTesting primary manipulators.\n");
465///
466/// for (size_t ti = 0; ti < 10; ++ti) {
467///
468/// if (veryVerbose) { T_ P(ti) }
469///
470/// Obj mL; const Obj& L = mL;
471/// assert(true == L.isNull());
472///
473/// const TYPE LV = TemplateTestFacility::create<TYPE>(ti);
474///
475/// mL.makeValue(LV);
476/// assert(false == L.isNull());
477/// assert(LV == L.value());
478///
479/// mL.makeNull();
480/// assert(true == L.isNull());
481/// }
482///
483/// if (verbose) printf("\nTesting destructor.\n");
484/// {
485/// Obj Z;
486/// }
487///
488/// assert(true == W.isNull());
489/// assert(XV == X.value());
490/// }
491/// @endcode
492/// Notice that, we create objects of the parameterized `TYPE` using the
493/// `TemplateTestFacility::create` class method template specifying an integer
494/// identifier; the created object has a value that is uniquely associated with
495/// the integer identifier.
496///
497/// Also notice that we verified that an object of the parameterized `TYPE` has
498/// the expected value in two ways:
499///
500/// 1. By equal comparing (1) the integer identifier returned from calling the
501/// `TemplateTestFacility::getIdentifier` class method template (specifying
502/// the object), and (2) the integer identifier uniquely associated with the
503/// expected state of the object.
504/// 2. By directly using the equality-comparison operator for the parameterized
505/// `TYPE`. Note that the equality-comparison operator is defined for all
506/// types intended for testing in the `bsltf` package except for
507/// `bsltf::NonEqualComparableTestType`.
508///
509/// Finally, we use the `BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE` macro to
510/// instantiate `MyTestDriver` for each of the types listed in
511/// `BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_REGULAR` and invoke the `testCase2`
512/// class method of each instantiation:
513/// @code
514/// case 2: {
515/// // ----------------------------------------------------------------------
516/// // DEFAULT CTOR & PRIMARY MANIPULATORS
517/// // ----------------------------------------------------------------------
518///
519/// if (verbose) printf("\nDEFAULT CTOR & PRIMARY MANIPULATORS"
520/// "\n===================================\n");
521///
522/// RUN_EACH_TYPE(MyTestDriver, testCase2, TEST_TYPES_REGULAR);
523/// } break;
524/// @endcode
525/// @}
526/** @} */
527/** @} */
528
529/** @addtogroup bsl
530 * @{
531 */
532/** @addtogroup bsltf
533 * @{
534 */
535/** @addtogroup bsltf_templatetestfacility
536 * @{
537 */
538
539#include <bslscm_version.h>
540
543#include <bsltf_alloctesttype.h>
551#include <bsltf_movestate.h>
558#include <bsltf_simpletesttype.h>
560#include <bsltf_uniontesttype.h>
562
565#include <bslma_bslallocator.h>
566
567#include <bslmf_assert.h>
568#include <bslmf_movableref.h>
569
570#include <bsls_assert.h>
571#include <bsls_objectbuffer.h>
572#include <bsls_types.h>
573#include <bsls_util.h>
574
575#include <stddef.h> // for 'size_t'
576#include <stdio.h> // for 'printf'
577
578#include <stdlib.h> // for 'atoi'
579
580
581namespace bsltf {
582
583 // ====================================
584 // class TemplateTestFacility_StubClass
585 // ====================================
586
587/// This class provides a single method template, `method`, that simply
588/// returns the parameterized integer `IDENTIFIER`. Note that the purpose
589/// of this class is to serve as a stub class and method to be referred by
590/// `TemplateTestFacility::ObjectPtr` and `TemplateTestFacility::MethodPtr`
591/// respectively.
592///
593/// See @ref bsltf_templatetestfacility
595
596 public:
597 // MANIPULATORS
598
599 /// Return the parameterized `IDENTIFIER`.
600 template <int IDENTIFIER>
601 int method();
602};
603
604 // ========================================
605 // class TemplateTestFacility_CompareHelper
606 // ========================================
607
609 public:
610 // CLASS METHODS
611 template <class TYPE>
612 static bool areEqual(const TYPE& lhs, const TYPE& rhs);
613
614 static bool areEqual(const NonEqualComparableTestType& lhs,
615 const NonEqualComparableTestType& rhs);
616
617 template <class TYPE>
618 static bool areNotEqual(const TYPE& lhs, const TYPE& rhs);
619
620 static bool areNotEqual(const NonEqualComparableTestType& lhs,
621 const NonEqualComparableTestType& rhs);
622};
623
624 // ===========================
625 // struct TemplateTestFacility
626 // ===========================
627
628/// This `struct` provides a namespace that contains three aliases for types
629/// intended to be used as template parameters for testing templates. The
630/// namespace also contain two class method templates, `create` and
631/// `getIdentifier`, that respectively provides a consistent interface to
632/// (1) create a specified object of a parameterized type from an integer
633/// identifier and (2) get the identifier value of a specified object. The
634/// identifier value returned from the `getIdentifier` method is undefined
635/// unless the specified object was originally created with the `create`
636/// class method template.
638
639 private:
640 /// Return a pointer to a null-terminated string that will parse as
641 /// having the same value as the specified `identifier`. The behavior
642 /// is undefined unless `0 <= identifier < 128`.
643 static const char* nullTerminatedStringForIdentifier(int identifier);
644
645 public:
646 // PUBLIC TYPES
647
648 /// This `typedef` is an alias for a pointer to a
649 /// `TemplateTestFacility_StubClass` object.
651
652 /// This `typedef` is an alias for a pointer to a function pointer.
653 typedef void (*FunctionPtr) ();
654
655 /// This `typedef` is an alias for a pointer to a method of
656 /// `TemplateTestFacility_StubClass` taking no arguments and returning
657 /// an `int`.
659
660 // CLASS METHODS
661
662 /// Return a new object of the parameterized `TYPE` whose state is
663 /// unique for the specified `identifier`. The behavior is undefined
664 /// unless `0 <= value < 128` and `TYPE` is contained in the macro
665 /// `BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_ALL`.
666 template <class TYPE>
667 static TYPE create(int identifier);
668
669 /// Create an object of the parameterized `TYPE` at the specified
670 /// `address` whose state is unique for the specified `identifier`. The
671 /// behavior is undefined unless `0 <= identifier < 128` and `TYPE` is
672 /// contained in the macro `BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_ALL`.
673 template <class TYPE, class ALLOCATOR>
674 static void emplace(TYPE *address, int identifier, ALLOCATOR allocator);
675 template <class TYPE, class ALLOCATOR>
676 static void emplace(TYPE *address, int identifier, ALLOCATOR *allocator);
677
678 /// Create a pointer to the parameterized `TYPE` at the specified
679 /// `address` whose value is unique for the specified `identifier`. The
680 /// behavior is undefined unless `0 <= identifier < 128`. Note that no
681 /// object is created at the address of the returned pointer, nor is it
682 /// guaranteed to be a valid address for an object (or function). Also
683 /// note that the same address may be returned for different allocators,
684 /// and is guaranteed to be unique only with respect to the `identifier`
685 /// value.
686 template <class TYPE, class ALLOCATOR>
687 static void emplace(TYPE **address, int identifier, ALLOCATOR allocator);
688 template <class TYPE, class ALLOCATOR>
689 static void emplace(TYPE **address, int identifier, ALLOCATOR *allocator);
690
691 /// Create at the specified `address` a pointer to a null-terminated
692 /// string that will parse as having the same value as the specified
693 /// `identifier`. The specified `allocator` is not used. The behavior
694 /// is undefined unless `0 <= identifier < 128`.
695 template <class ALLOCATOR>
696 static void
697 emplace(const char **address, int identifier, ALLOCATOR allocator);
698 template <class ALLOCATOR>
699 static void
700 emplace(const char **address, int identifier, ALLOCATOR *allocator);
701
702 template <class ALLOCATOR>
703 static void emplace(char *address, int identifier, ALLOCATOR allocator);
704 template <class ALLOCATOR>
705 static void
706 emplace(char *address, int identifier, ALLOCATOR *allocator);
707 template <class ALLOCATOR>
708 static void
709 emplace(signed char *address, int identifier, ALLOCATOR allocator);
710 template <class ALLOCATOR>
711 static void
712 emplace(signed char *address, int identifier, ALLOCATOR *allocator);
713 template <class ALLOCATOR>
714 static void
715 emplace(unsigned char *address, int identifier, ALLOCATOR allocator);
716 template <class ALLOCATOR>
717 static void
718 emplace(unsigned char *address, int identifier, ALLOCATOR *allocator);
719
720 /// Set the character object at the specified `address` to the value of
721 /// the specified `identifier`. The specified `allocator` is not used.
722 /// The behavior is undefined unless `0 <= identifier < 128`. Note that
723 /// these overloads are needed only to avoid narrowing conversion
724 /// warnings that will occur in lower-level utilities when using this
725 /// test facility.
726 template <class ALLOCATOR>
727
728 static void
729 emplace(EmplacableTestType *address, int identifier, ALLOCATOR allocator);
730 template <class ALLOCATOR>
731 static void
732 emplace(EmplacableTestType *address, int identifier, ALLOCATOR *allocator);
733
734 template <class ALLOCATOR>
735 static void
737 int identifier,
738 ALLOCATOR allocator);
739 template <class ALLOCATOR>
740 static void
742 int identifier,
743 ALLOCATOR *allocator);
744
745 /// Set the enumeration at the specified `address` to the value of the
746 /// specified `identifier`. The specified `allocator` is not used. The
747 /// behavior is undefined unless `0 <= identifier < 128`.
748 template <class ALLOCATOR>
749 static void emplace(EnumeratedTestType::Enum *address,
750 int identifier,
751 ALLOCATOR allocator);
752 template <class ALLOCATOR>
753 static void emplace(EnumeratedTestType::Enum *address,
754 int identifier,
755 ALLOCATOR *allocator);
756
757 /// Set the pointer-to-method at the specified `address` to the value of
758 /// the specified `identifier`. The specified `allocator` is not used.
759 /// The behavior is undefined unless `0 <= identifier < 128`.
760 template <class ALLOCATOR>
761 static void
762 emplace(MethodPtr *address, int identifier, ALLOCATOR allocator);
763 template <class ALLOCATOR>
764 static void
765 emplace(MethodPtr *address, int identifier, ALLOCATOR *allocator);
766
767 /// Return the integer identifier that uniquely identifies the specified
768 /// `object`. The behavior is undefined unless `object` could be
769 /// created from the `TemplateTestFacility::create` class method
770 /// template.
771 template <class TYPE>
772 static int getIdentifier(const TYPE& object);
773
774 /// Return the integer identifier that uniquely identifies the specified
775 /// `object`. The behavior is undefined unless `object` was created by
776 /// a call to the `TemplateTestFacility::create` class method template,
777 /// or is a copy of such an object.
778 template <class TYPE>
779 static int getIdentifier(TYPE*const& object);
780
781 /// Return the integer identifier that uniquely identifies the specified
782 /// `object`. The behavior is undefined unless `object` could be
783 /// created from the `TemplateTestFacility::create` class method
784 /// template.
785 static int getIdentifier(const char*const& object);
786
787 /// Return the integer identifier that uniquely identifies the specified
788 /// `object`. The behavior is undefined unless `object` could be
789 /// created from the `TemplateTestFacility::create` class method
790 /// template.
791 template <class ALLOC>
792 static int getIdentifier(const StdAllocTestType<ALLOC>& object);
793
794 /// Return the moved-from state of the specified `object, or `e_UNKNOWN'
795 /// if (template parameter) `TYPE` does not support such a query.
796 template <class TYPE>
797 static bsltf::MoveState::Enum getMovedFromState(const TYPE& object);
798
799 /// Return the moved-into state of the specified `object, or `e_UNKNOWN'
800 /// if (template parameter) `TYPE` does not support such a query.
801 template <class TYPE>
802 static bsltf::MoveState::Enum getMovedIntoState(const TYPE& object);
803
804 /// Set the moved-into state of the specified 'object to the specified
805 /// `value` if (template parameter) `TYPE` does supports move states.
806 template <class TYPE>
807 static void setMovedIntoState(TYPE *object, bsltf::MoveState::Enum value);
808};
809
810// FREE FUNCTIONS
811
812void debugprint(const AllocTestType& obj);
813void debugprint(const NonOptionalAllocTestType& obj);
815void debugprint(const AllocEmplacableTestType& obj);
816void debugprint(const BitwiseCopyableTestType& obj);
817void debugprint(const BitwiseMoveableTestType& obj);
818void debugprint(const EmplacableTestType& obj);
819void debugprint(const EnumeratedTestType::Enum& obj);
820void debugprint(const MovableAllocTestType& obj);
821void debugprint(const MovableTestType& obj);
822void debugprint(const MoveOnlyAllocTestType& obj);
824void debugprint(const NonAssignableTestType& obj);
828/// Print the value of the specified `obj` to the console. Note that this
829/// free function is provided to allow @ref bsls_bsltestutil to support these
830/// types intended for testing. See the component-level documentation for
831/// @ref bsls_bsltestutil for more details.
832void debugprint(const SimpleTestType& obj);
833template <class ALLOC> void debugprint(const StdAllocTestType<ALLOC>& obj);
834void debugprint(const UnionTestType& obj);
836
837 // =================
838 // Macro Definitions
839 // =================
840
841/// This macro refers to all of the primitive test types defined in this
842/// package. Note that it can be used as the last argument to the
843/// `BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE` macro.
844#define BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_PRIMITIVE \
845 signed char, \
846 size_t, \
847 const char *, \
848 bsltf::TemplateTestFacility::ObjectPtr, \
849 bsltf::TemplateTestFacility::FunctionPtr, \
850 bsltf::TemplateTestFacility::MethodPtr
851
852/// This macro refers to all of the user-defined test types defined in this
853/// package. Note that the macro can be used as the last argument to the
854/// `BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE` macro.
855#define BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_USER_DEFINED \
856 bsltf::EnumeratedTestType::Enum, \
857 bsltf::UnionTestType, \
858 bsltf::SimpleTestType, \
859 bsltf::AllocTestType, \
860 bsltf::BitwiseCopyableTestType, \
861 bsltf::BitwiseMoveableTestType, \
862 bsltf::AllocBitwiseMoveableTestType, \
863 bsltf::MovableTestType, \
864 bsltf::MovableAllocTestType, \
865 bsltf::NonTypicalOverloadsTestType
866
867/// This macro refers to all of the regular test types defined in this
868/// package. Note that the macro can be used as the last argument to the
869/// `BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE` macro.
870#define BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_REGULAR \
871 BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_PRIMITIVE, \
872 BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_USER_DEFINED
873
874#define BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_AWKWARD \
875 bsltf::NonAssignableTestType, \
876 bsltf::NonDefaultConstructibleTestType, \
877 bsltf::NonEqualComparableTestType
878 // TBD: move-only types should be in a separate movable macro, as many
879 // existing test rely on copying.
880 // bsltf::MoveOnlyAllocTestType
881 // TBD: cannot add following as they support only 14 valid values, and
882 // 'create'/'getIdentifier' require support for (at least) 128
883 // distinct values. 'bool' has the same issue, as do empty types.
884 // bsltf::AllocEmplacableTestType
885 // bsltf::EmplacableTestType
886 // This macro refers to all of the awkward test types defined in this
887 // package. Note that the macro can be used as the last argument to the
888 // 'BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE' macro.
889
890/// This macro refers to all of the test types defined in this package.
891/// Note that the macro can be used as the last argument to the
892/// `BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE` macro.
893#define BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_ALL \
894 BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_REGULAR, \
895 BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_AWKWARD
896
897
898#define BSLTF_TEMPLATETESTFACILITY_NUM_ARGS_IMPL(X20, X19, X18, X17, X16, \
899 X15, X14, X13, X12, X11, \
900 X10, X9, X8, X7, X6, \
901 X5, X4, X3, X2, X1, \
902 N, ...) \
903 N
904
905// The 'BSLTF_TEMPLATETESTFACILITY_EXPAND' macro is required to workaround a
906// pre-processor issue on windows that prevents __VA_ARGS__ to be expanded in
907// the definition of some macros.
908#define BSLTF_TEMPLATETESTFACILITY_EXPAND(X) \
909 X
910
911#define BSLTF_TEMPLATETESTFACILITY_NUM_ARGS(...) \
912 BSLTF_TEMPLATETESTFACILITY_EXPAND( \
913 BSLTF_TEMPLATETESTFACILITY_NUM_ARGS_IMPL(__VA_ARGS__, \
914 20, 19, 18, 17, 16, 15, 14, \
915 13, 12, 11, 10, 9, 8, 7, \
916 6, 5, 4, 3, 2, 1, 0))
917
918#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL1(C, M, T1) \
919 C<T1>::M();
920
921#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL2(C, M, T1, T2) \
922 C<T1>::M(); C<T2>::M();
923
924#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL3(C, M, T1, T2, T3) \
925 C<T1>::M(); C<T2>::M(); C<T3>::M();
926
927#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL4(C, M, T1, T2, T3, T4) \
928 C<T1>::M(); C<T2>::M(); C<T3>::M(); C<T4>::M();
929
930#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL5(C, M, T1, T2, T3, T4, \
931 T5) \
932 C<T1>::M(); C<T2>::M(); C<T3>::M(); C<T4>::M(); C<T5>::M();
933
934#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL6(C, M, T1, T2, T3, T4, \
935 T5, T6) \
936 C<T1>::M(); C<T2>::M(); C<T3>::M(); C<T4>::M(); C<T5>::M(); \
937 C<T6>::M();
938
939#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL7(C, M, T1, T2, T3, T4, \
940 T5, T6, T7) \
941 C<T1>::M(); C<T2>::M(); C<T3>::M(); C<T4>::M(); C<T5>::M(); \
942 C<T6>::M(); C<T7>::M();
943
944#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL8(C, M, T1, T2, T3, T4, \
945 T5, T6, T7, T8) \
946 C<T1>::M(); C<T2>::M(); C<T3>::M(); C<T4>::M(); C<T5>::M(); \
947 C<T6>::M(); C<T7>::M(); C<T8>::M();
948
949#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL9(C, M, T1, T2, T3, T4, \
950 T5, T6, T7, T8, T9) \
951 C<T1>::M(); C<T2>::M(); C<T3>::M(); C<T4>::M(); C<T5>::M(); \
952 C<T6>::M(); C<T7>::M(); C<T8>::M(); C<T9>::M();
953
954#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL10(C, M, T1, T2, T3, T4, \
955 T5, T6, T7, T8, T9, \
956 T10) \
957 C<T1>::M(); C<T2>::M(); C<T3>::M(); C<T4>::M(); C<T5>::M(); \
958 C<T6>::M(); C<T7>::M(); C<T8>::M(); C<T9>::M(); C<T10>::M();
959
960#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL11(C, M, T1, T2, T3, T4, \
961 T5, T6, T7, T8, T9, \
962 T10, T11) \
963 C<T1>::M(); C<T2>::M(); C<T3>::M(); C<T4>::M(); C<T5>::M(); \
964 C<T6>::M(); C<T7>::M(); C<T8>::M(); C<T9>::M(); C<T10>::M(); \
965 C<T11>::M();
966
967#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL12(C, M, T1, T2, T3, T4, \
968 T5, T6, T7, T8, T9, \
969 T10, T11, T12) \
970 C<T1>::M(); C<T2>::M(); C<T3>::M(); C<T4>::M(); C<T5>::M(); \
971 C<T6>::M(); C<T7>::M(); C<T8>::M(); C<T9>::M(); C<T10>::M(); \
972 C<T11>::M(); C<T12>::M();
973
974#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL13(C, M, T1, T2, T3, T4, \
975 T5, T6, T7, T8, T9, \
976 T10, T11, T12, T13) \
977 C<T1>::M(); C<T2>::M(); C<T3>::M(); C<T4>::M(); C<T5>::M(); \
978 C<T6>::M(); C<T7>::M(); C<T8>::M(); C<T9>::M(); C<T10>::M(); \
979 C<T11>::M(); C<T12>::M(); C<T13>::M();
980
981#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL14(C, M, T1, T2, T3, T4, \
982 T5, T6, T7, T8, T9, \
983 T10, T11, T12, T13, \
984 T14) \
985 C<T1>::M(); C<T2>::M(); C<T3>::M(); C<T4>::M(); C<T5>::M(); \
986 C<T6>::M(); C<T7>::M(); C<T8>::M(); C<T9>::M(); C<T10>::M(); \
987 C<T11>::M(); C<T12>::M(); C<T13>::M(); C<T14>::M();
988
989#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL15(C, M, T1, T2, T3, T4, \
990 T5, T6, T7, T8, T9, \
991 T10, T11, T12, T13, \
992 T14, T15) \
993 C<T1>::M(); C<T2>::M(); C<T3>::M(); C<T4>::M(); C<T5>::M(); \
994 C<T6>::M(); C<T7>::M(); C<T8>::M(); C<T9>::M(); C<T10>::M(); \
995 C<T11>::M(); C<T12>::M(); C<T13>::M(); C<T14>::M(); C<T15>::M();
996
997#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL16(C, M, T1, T2, T3, T4, \
998 T5, T6, T7, T8, T9, \
999 T10, T11, T12, T13, \
1000 T14, T15, T16) \
1001 C<T1>::M(); C<T2>::M(); C<T3>::M(); C<T4>::M(); C<T5>::M(); \
1002 C<T6>::M(); C<T7>::M(); C<T8>::M(); C<T9>::M(); C<T10>::M(); \
1003 C<T11>::M(); C<T12>::M(); C<T13>::M(); C<T14>::M(); C<T15>::M(); \
1004 C<T16>::M();
1005
1006#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL17(C, M, T1, T2, T3, T4, \
1007 T5, T6, T7, T8, T9, \
1008 T10, T11, T12, T13, \
1009 T14, T15, T16, T17) \
1010 C<T1>::M(); C<T2>::M(); C<T3>::M(); C<T4>::M(); C<T5>::M(); \
1011 C<T6>::M(); C<T7>::M(); C<T8>::M(); C<T9>::M(); C<T10>::M(); \
1012 C<T11>::M(); C<T12>::M(); C<T13>::M(); C<T14>::M(); C<T15>::M(); \
1013 C<T16>::M(); C<T17>::M();
1014
1015#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL18(C, M, T1, T2, T3, T4, \
1016 T5, T6, T7, T8, T9, \
1017 T10, T11, T12, T13, \
1018 T14, T15, T16, T17, \
1019 T18) \
1020 C<T1>::M(); C<T2>::M(); C<T3>::M(); C<T4>::M(); C<T5>::M(); \
1021 C<T6>::M(); C<T7>::M(); C<T8>::M(); C<T9>::M(); C<T10>::M(); \
1022 C<T11>::M(); C<T12>::M(); C<T13>::M(); C<T14>::M(); C<T15>::M(); \
1023 C<T16>::M(); C<T17>::M(); C<T18>::M();
1024
1025#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL19(C, M, T1, T2, T3, T4, \
1026 T5, T6, T7, T8, T9, \
1027 T10, T11, T12, T13, \
1028 T14, T15, T16, T17, \
1029 T18, T19) \
1030 C<T1>::M(); C<T2>::M(); C<T3>::M(); C<T4>::M(); C<T5>::M(); \
1031 C<T6>::M(); C<T7>::M(); C<T8>::M(); C<T9>::M(); C<T10>::M(); \
1032 C<T11>::M(); C<T12>::M(); C<T13>::M(); C<T14>::M(); C<T15>::M(); \
1033 C<T16>::M(); C<T17>::M(); C<T18>::M(); C<T19>::M();
1034
1035#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL20(C, M, T1, T2, T3, T4, \
1036 T5, T6, T7, T8, T9, \
1037 T10, T11, T12, T13, \
1038 T14, T15, T16, T17, \
1039 T18, T19, T20) \
1040 C<T1>::M(); C<T2>::M(); C<T3>::M(); C<T4>::M(); C<T5>::M(); \
1041 C<T6>::M(); C<T7>::M(); C<T8>::M(); C<T9>::M(); C<T10>::M(); \
1042 C<T11>::M(); C<T12>::M(); C<T13>::M(); C<T14>::M(); C<T15>::M(); \
1043 C<T16>::M(); C<T17>::M(); C<T18>::M(); C<T19>::M(); C<T20>::M();
1044
1045#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL(C, M, N, ...) \
1046 BSLTF_TEMPLATETESTFACILITY_EXPAND( \
1047 BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL ## N(C, M, __VA_ARGS__))
1048
1049#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_(C, M, N, ...) \
1050 BSLTF_TEMPLATETESTFACILITY_EXPAND( \
1051 BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_IMPL(C, M, N, __VA_ARGS__))
1052
1053#define BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE(CLASS, METHOD, ...) \
1054 BSLTF_TEMPLATETESTFACILITY_RUN_EACH_TYPE_( \
1055 CLASS, \
1056 METHOD, \
1057 BSLTF_TEMPLATETESTFACILITY_NUM_ARGS(__VA_ARGS__), \
1058 __VA_ARGS__) \
1059 // Instantiates the specified 'CLASS' for each of the types specified
1060 // in the third to last arguments of this macro. Call the specified
1061 // class 'METHOD' of each instantiation. The compilation will fail if
1062 // the number of specified types is more than 20.
1063
1064#define BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_DEFINE_DBG_PRINT(TYPE) \
1065 inline void dbg_print(const TYPE& val) \
1066 { printf("%d", bsltf::TemplateTestFacility::getIdentifier<TYPE>(val)); }
1067
1068#define BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_DEFINE_DBG_PRINTS() \
1069 BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_DEFINE_DBG_PRINT( \
1070 bsltf::EnumeratedTestType::Enum) \
1071 \
1072 BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_DEFINE_DBG_PRINT( \
1073 bsltf::UnionTestType) \
1074 \
1075 BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_DEFINE_DBG_PRINT( \
1076 bsltf::SimpleTestType) \
1077 \
1078 BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_DEFINE_DBG_PRINT( \
1079 bsltf::AllocTestType) \
1080 \
1081 BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_DEFINE_DBG_PRINT( \
1082 bsltf::NonOptionalAllocTestType) \
1083 \
1084 BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_DEFINE_DBG_PRINT( \
1085 bsltf::MovableAllocTestType) \
1086 \
1087 BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_DEFINE_DBG_PRINT( \
1088 bsltf::MovableTestType) \
1089 \
1090 BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_DEFINE_DBG_PRINT( \
1091 bsltf::MoveOnlyAllocTestType) \
1092 \
1093 BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_DEFINE_DBG_PRINT( \
1094 bsltf::AllocEmplacableTestType) \
1095 \
1096 BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_DEFINE_DBG_PRINT( \
1097 bsltf::EmplacableTestType) \
1098 \
1099 BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_DEFINE_DBG_PRINT( \
1100 bsltf::BitwiseCopyableTestType) \
1101 \
1102 BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_DEFINE_DBG_PRINT( \
1103 bsltf::BitwiseMoveableTestType) \
1104 \
1105 BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_DEFINE_DBG_PRINT( \
1106 bsltf::AllocBitwiseMoveableTestType) \
1107 \
1108 BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_DEFINE_DBG_PRINT( \
1109 bsltf::NonTypicalOverloadsTestType) \
1110 \
1111 BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_DEFINE_DBG_PRINT( \
1112 bsltf::NonCopyConstructibleTestType) \
1113 \
1114 BSLTF_TEMPLATETESTFACILITY_TEST_TYPES_DEFINE_DBG_PRINT( \
1115 bsltf::NonDefaultConstructibleTestType)
1116
1117 // Defines a list of @ref dbg_print overloads for use in the test driver.
1118 // FIXME: Change this to integrate with Alisdair's test driver print
1119 // facility once its ready.
1120
1121#define BSLTF_TEMPLATETESTFACILITY_COMPARE_EQUAL(FIRST_ARGUMENT, \
1122 SECOND_ARGUMENT) \
1123 ::BloombergLP::bsltf::TemplateTestFacility_CompareHelper:: \
1124 areEqual(FIRST_ARGUMENT, SECOND_ARGUMENT)
1125
1126#define BSLTF_TEMPLATETESTFACILITY_COMPARE_NOT_EQUAL(FIRST_ARGUMENT, \
1127 SECOND_ARGUMENT) \
1128 ::BloombergLP::bsltf::TemplateTestFacility_CompareHelper:: \
1129 areNotEqual(FIRST_ARGUMENT, SECOND_ARGUMENT)
1130
1131// ============================================================================
1132// INLINE FUNCTION DEFINITIONS
1133// ============================================================================
1134
1135 // ------------------------------------
1136 // class TemplateTestFacility_StubClass
1137 // ------------------------------------
1138
1139template <int IDENTIFIER>
1141{
1142 return IDENTIFIER;
1143}
1144
1145 // ----------------------------------------
1146 // class TemplateTestFacility_CompareHelper
1147 // ----------------------------------------
1148
1149template <class TYPE>
1150inline
1152 const TYPE& rhs)
1153{
1154 return lhs == rhs;
1155}
1156
1157template <class TYPE>
1158inline
1160 const TYPE& rhs)
1161{
1162 return lhs != rhs;
1163}
1164
1165inline
1167 const NonEqualComparableTestType& lhs,
1168 const NonEqualComparableTestType& rhs)
1169{
1170 return lhs.data() == rhs.data();
1171}
1172
1173inline
1175 const NonEqualComparableTestType& lhs,
1176 const NonEqualComparableTestType& rhs)
1177{
1178 return lhs.data() != rhs.data();
1179}
1180
1181 // ---------------------------
1182 // struct TemplateTestFacility
1183 // ---------------------------
1184
1185// CLASS METHODS
1186template <class TYPE>
1187inline
1189{
1191 emplace(obj.address(),
1192 identifier,
1194 return TYPE(bslmf::MovableRefUtil::move(obj.object()));
1195}
1196
1197template <class TYPE, class ALLOCATOR>
1198inline
1200 int identifier,
1201 ALLOCATOR allocator)
1202{
1203 BSLS_ASSERT_SAFE(address);
1204 BSLS_ASSERT_SAFE(0 <= identifier); BSLS_ASSERT_SAFE(identifier < 128);
1205
1207 allocator, address, identifier);
1208}
1209
1210template <class TYPE, class ALLOCATOR>
1211inline
1213 int identifier,
1214 ALLOCATOR *allocator)
1215{
1216 emplace(address, identifier, bsl::allocator<TYPE>(allocator));
1217}
1218
1219template <class TYPE, class ALLOCATOR>
1220inline
1221void TemplateTestFacility::emplace(TYPE **address, int identifier, ALLOCATOR)
1222{
1223 BSLS_ASSERT_SAFE(address);
1224 BSLS_ASSERT_SAFE(0 <= identifier); BSLS_ASSERT_SAFE(identifier < 128);
1225
1226 *address = reinterpret_cast<TYPE *>(bsls::Types::IntPtr(identifier));
1227}
1228
1229template <class TYPE, class ALLOCATOR>
1230inline
1231void TemplateTestFacility::emplace(TYPE **address, int identifier, ALLOCATOR *)
1232{
1233 BSLS_ASSERT_SAFE(address);
1234 BSLS_ASSERT_SAFE(0 <= identifier); BSLS_ASSERT_SAFE(identifier < 128);
1235
1236 *address = reinterpret_cast<TYPE *>(bsls::Types::IntPtr(identifier));
1237}
1238
1239template <class ALLOCATOR>
1240void TemplateTestFacility::emplace(const char **address,
1241 int identifier,
1242 ALLOCATOR allocator)
1243{
1244 BSLS_ASSERT_SAFE(address);
1245 BSLS_ASSERT_SAFE(0 <= identifier); BSLS_ASSERT_SAFE(identifier < 128);
1246
1247 (void)allocator;
1248
1249 *address = nullTerminatedStringForIdentifier(identifier);
1250}
1251
1252template <class ALLOCATOR>
1253void TemplateTestFacility::emplace(const char **address,
1254 int identifier,
1255 ALLOCATOR *allocator)
1256{
1257 BSLS_ASSERT_SAFE(address);
1258 BSLS_ASSERT_SAFE(0 <= identifier); BSLS_ASSERT_SAFE(identifier < 128);
1259
1260 (void)allocator;
1261
1262 *address = nullTerminatedStringForIdentifier(identifier);
1263}
1264
1265template <class ALLOCATOR>
1266inline
1267void TemplateTestFacility::emplace(char *address, int identifier, ALLOCATOR)
1268{
1269 BSLS_ASSERT_SAFE(address);
1270 BSLS_ASSERT_SAFE(0 <= identifier); BSLS_ASSERT_SAFE(identifier < 128);
1271
1272 *address = static_cast<char>(identifier);
1273}
1274
1275template <class ALLOCATOR>
1276inline
1278 int identifier,
1279 ALLOCATOR *)
1280{
1281 BSLS_ASSERT_SAFE(address);
1282 BSLS_ASSERT_SAFE(0 <= identifier); BSLS_ASSERT_SAFE(identifier < 128);
1283
1284 *address = static_cast<char>(identifier);
1285}
1286
1287template <class ALLOCATOR>
1288inline
1289void TemplateTestFacility::emplace(signed char *address,
1290 int identifier,
1291 ALLOCATOR)
1292{
1293 BSLS_ASSERT_SAFE(address);
1294 BSLS_ASSERT_SAFE(0 <= identifier); BSLS_ASSERT_SAFE(identifier < 128);
1295
1296 *address = static_cast<signed char>(identifier);
1297}
1298
1299template <class ALLOCATOR>
1300inline
1301void TemplateTestFacility::emplace(signed char *address,
1302 int identifier,
1303 ALLOCATOR *)
1304{
1305 BSLS_ASSERT_SAFE(address);
1306 BSLS_ASSERT_SAFE(0 <= identifier); BSLS_ASSERT_SAFE(identifier < 128);
1307
1308 *address = static_cast<signed char>(identifier);
1309}
1310
1311template <class ALLOCATOR>
1312inline
1314 int identifier,
1315 ALLOCATOR)
1316{
1317 BSLS_ASSERT_SAFE(address);
1318 BSLS_ASSERT_SAFE(0 <= identifier); BSLS_ASSERT_SAFE(identifier < 128);
1319
1320 *address = static_cast<EnumeratedTestType::Enum>(identifier);
1321}
1322
1323template <class ALLOCATOR>
1324inline
1326 int identifier,
1327 ALLOCATOR *)
1328{
1329 BSLS_ASSERT_SAFE(address);
1330 BSLS_ASSERT_SAFE(0 <= identifier); BSLS_ASSERT_SAFE(identifier < 128);
1331
1332 *address = static_cast<EnumeratedTestType::Enum>(identifier);
1333}
1334
1335template <class ALLOCATOR>
1336inline
1338 int identifier,
1339 ALLOCATOR)
1340{
1341 BSLS_ASSERT_SAFE(address);
1342 BSLS_ASSERT_SAFE(0 <= identifier); BSLS_ASSERT_SAFE(identifier < 128);
1343
1344 switch (identifier) {
1345 case 0: *address = 0 ; break;
1346 case 1: *address = &TemplateTestFacility_StubClass::method< 1>; break;
1347 case 2: *address = &TemplateTestFacility_StubClass::method< 2>; break;
1348 case 3: *address = &TemplateTestFacility_StubClass::method< 3>; break;
1349 case 4: *address = &TemplateTestFacility_StubClass::method< 4>; break;
1350 case 5: *address = &TemplateTestFacility_StubClass::method< 5>; break;
1351 case 6: *address = &TemplateTestFacility_StubClass::method< 6>; break;
1352 case 7: *address = &TemplateTestFacility_StubClass::method< 7>; break;
1353 case 8: *address = &TemplateTestFacility_StubClass::method< 8>; break;
1354 case 9: *address = &TemplateTestFacility_StubClass::method< 9>; break;
1355 case 10: *address = &TemplateTestFacility_StubClass::method< 10>; break;
1356 case 11: *address = &TemplateTestFacility_StubClass::method< 11>; break;
1357 case 12: *address = &TemplateTestFacility_StubClass::method< 12>; break;
1358 case 13: *address = &TemplateTestFacility_StubClass::method< 13>; break;
1359 case 14: *address = &TemplateTestFacility_StubClass::method< 14>; break;
1360 case 15: *address = &TemplateTestFacility_StubClass::method< 15>; break;
1361 case 16: *address = &TemplateTestFacility_StubClass::method< 16>; break;
1362 case 17: *address = &TemplateTestFacility_StubClass::method< 17>; break;
1363 case 18: *address = &TemplateTestFacility_StubClass::method< 18>; break;
1364 case 19: *address = &TemplateTestFacility_StubClass::method< 19>; break;
1365 case 20: *address = &TemplateTestFacility_StubClass::method< 20>; break;
1366 case 21: *address = &TemplateTestFacility_StubClass::method< 21>; break;
1367 case 22: *address = &TemplateTestFacility_StubClass::method< 22>; break;
1368 case 23: *address = &TemplateTestFacility_StubClass::method< 23>; break;
1369 case 24: *address = &TemplateTestFacility_StubClass::method< 24>; break;
1370 case 25: *address = &TemplateTestFacility_StubClass::method< 25>; break;
1371 case 26: *address = &TemplateTestFacility_StubClass::method< 26>; break;
1372 case 27: *address = &TemplateTestFacility_StubClass::method< 27>; break;
1373 case 28: *address = &TemplateTestFacility_StubClass::method< 28>; break;
1374 case 29: *address = &TemplateTestFacility_StubClass::method< 29>; break;
1375 case 30: *address = &TemplateTestFacility_StubClass::method< 30>; break;
1376 case 31: *address = &TemplateTestFacility_StubClass::method< 31>; break;
1377 case 32: *address = &TemplateTestFacility_StubClass::method< 32>; break;
1378 case 33: *address = &TemplateTestFacility_StubClass::method< 33>; break;
1379 case 34: *address = &TemplateTestFacility_StubClass::method< 34>; break;
1380 case 35: *address = &TemplateTestFacility_StubClass::method< 35>; break;
1381 case 36: *address = &TemplateTestFacility_StubClass::method< 36>; break;
1382 case 37: *address = &TemplateTestFacility_StubClass::method< 37>; break;
1383 case 38: *address = &TemplateTestFacility_StubClass::method< 38>; break;
1384 case 39: *address = &TemplateTestFacility_StubClass::method< 39>; break;
1385 case 40: *address = &TemplateTestFacility_StubClass::method< 40>; break;
1386 case 41: *address = &TemplateTestFacility_StubClass::method< 41>; break;
1387 case 42: *address = &TemplateTestFacility_StubClass::method< 42>; break;
1388 case 43: *address = &TemplateTestFacility_StubClass::method< 43>; break;
1389 case 44: *address = &TemplateTestFacility_StubClass::method< 44>; break;
1390 case 45: *address = &TemplateTestFacility_StubClass::method< 45>; break;
1391 case 46: *address = &TemplateTestFacility_StubClass::method< 46>; break;
1392 case 47: *address = &TemplateTestFacility_StubClass::method< 47>; break;
1393 case 48: *address = &TemplateTestFacility_StubClass::method< 48>; break;
1394 case 49: *address = &TemplateTestFacility_StubClass::method< 49>; break;
1395 case 50: *address = &TemplateTestFacility_StubClass::method< 50>; break;
1396 case 51: *address = &TemplateTestFacility_StubClass::method< 51>; break;
1397 case 52: *address = &TemplateTestFacility_StubClass::method< 52>; break;
1398 case 53: *address = &TemplateTestFacility_StubClass::method< 53>; break;
1399 case 54: *address = &TemplateTestFacility_StubClass::method< 54>; break;
1400 case 55: *address = &TemplateTestFacility_StubClass::method< 55>; break;
1401 case 56: *address = &TemplateTestFacility_StubClass::method< 56>; break;
1402 case 57: *address = &TemplateTestFacility_StubClass::method< 57>; break;
1403 case 58: *address = &TemplateTestFacility_StubClass::method< 58>; break;
1404 case 59: *address = &TemplateTestFacility_StubClass::method< 59>; break;
1405 case 60: *address = &TemplateTestFacility_StubClass::method< 60>; break;
1406 case 61: *address = &TemplateTestFacility_StubClass::method< 61>; break;
1407 case 62: *address = &TemplateTestFacility_StubClass::method< 62>; break;
1408 case 63: *address = &TemplateTestFacility_StubClass::method< 63>; break;
1409 case 64: *address = &TemplateTestFacility_StubClass::method< 64>; break;
1410 case 65: *address = &TemplateTestFacility_StubClass::method< 65>; break;
1411 case 66: *address = &TemplateTestFacility_StubClass::method< 66>; break;
1412 case 67: *address = &TemplateTestFacility_StubClass::method< 67>; break;
1413 case 68: *address = &TemplateTestFacility_StubClass::method< 68>; break;
1414 case 69: *address = &TemplateTestFacility_StubClass::method< 69>; break;
1415 case 70: *address = &TemplateTestFacility_StubClass::method< 70>; break;
1416 case 71: *address = &TemplateTestFacility_StubClass::method< 71>; break;
1417 case 72: *address = &TemplateTestFacility_StubClass::method< 72>; break;
1418 case 73: *address = &TemplateTestFacility_StubClass::method< 73>; break;
1419 case 74: *address = &TemplateTestFacility_StubClass::method< 74>; break;
1420 case 75: *address = &TemplateTestFacility_StubClass::method< 75>; break;
1421 case 76: *address = &TemplateTestFacility_StubClass::method< 76>; break;
1422 case 77: *address = &TemplateTestFacility_StubClass::method< 77>; break;
1423 case 78: *address = &TemplateTestFacility_StubClass::method< 78>; break;
1424 case 79: *address = &TemplateTestFacility_StubClass::method< 79>; break;
1425 case 80: *address = &TemplateTestFacility_StubClass::method< 80>; break;
1426 case 81: *address = &TemplateTestFacility_StubClass::method< 81>; break;
1427 case 82: *address = &TemplateTestFacility_StubClass::method< 82>; break;
1428 case 83: *address = &TemplateTestFacility_StubClass::method< 83>; break;
1429 case 84: *address = &TemplateTestFacility_StubClass::method< 84>; break;
1430 case 85: *address = &TemplateTestFacility_StubClass::method< 85>; break;
1431 case 86: *address = &TemplateTestFacility_StubClass::method< 86>; break;
1432 case 87: *address = &TemplateTestFacility_StubClass::method< 87>; break;
1433 case 88: *address = &TemplateTestFacility_StubClass::method< 88>; break;
1434 case 89: *address = &TemplateTestFacility_StubClass::method< 89>; break;
1435 case 90: *address = &TemplateTestFacility_StubClass::method< 90>; break;
1436 case 91: *address = &TemplateTestFacility_StubClass::method< 91>; break;
1437 case 92: *address = &TemplateTestFacility_StubClass::method< 92>; break;
1438 case 93: *address = &TemplateTestFacility_StubClass::method< 93>; break;
1439 case 94: *address = &TemplateTestFacility_StubClass::method< 94>; break;
1440 case 95: *address = &TemplateTestFacility_StubClass::method< 95>; break;
1441 case 96: *address = &TemplateTestFacility_StubClass::method< 96>; break;
1442 case 97: *address = &TemplateTestFacility_StubClass::method< 97>; break;
1443 case 98: *address = &TemplateTestFacility_StubClass::method< 98>; break;
1444 case 99: *address = &TemplateTestFacility_StubClass::method< 99>; break;
1445 case 100: *address = &TemplateTestFacility_StubClass::method<100>; break;
1446 case 101: *address = &TemplateTestFacility_StubClass::method<101>; break;
1447 case 102: *address = &TemplateTestFacility_StubClass::method<102>; break;
1448 case 103: *address = &TemplateTestFacility_StubClass::method<103>; break;
1449 case 104: *address = &TemplateTestFacility_StubClass::method<104>; break;
1450 case 105: *address = &TemplateTestFacility_StubClass::method<105>; break;
1451 case 106: *address = &TemplateTestFacility_StubClass::method<106>; break;
1452 case 107: *address = &TemplateTestFacility_StubClass::method<107>; break;
1453 case 108: *address = &TemplateTestFacility_StubClass::method<108>; break;
1454 case 109: *address = &TemplateTestFacility_StubClass::method<109>; break;
1455 case 110: *address = &TemplateTestFacility_StubClass::method<110>; break;
1456 case 111: *address = &TemplateTestFacility_StubClass::method<111>; break;
1457 case 112: *address = &TemplateTestFacility_StubClass::method<112>; break;
1458 case 113: *address = &TemplateTestFacility_StubClass::method<113>; break;
1459 case 114: *address = &TemplateTestFacility_StubClass::method<114>; break;
1460 case 115: *address = &TemplateTestFacility_StubClass::method<115>; break;
1461 case 116: *address = &TemplateTestFacility_StubClass::method<116>; break;
1462 case 117: *address = &TemplateTestFacility_StubClass::method<117>; break;
1463 case 118: *address = &TemplateTestFacility_StubClass::method<118>; break;
1464 case 119: *address = &TemplateTestFacility_StubClass::method<119>; break;
1465 case 120: *address = &TemplateTestFacility_StubClass::method<120>; break;
1466 case 121: *address = &TemplateTestFacility_StubClass::method<121>; break;
1467 case 122: *address = &TemplateTestFacility_StubClass::method<122>; break;
1468 case 123: *address = &TemplateTestFacility_StubClass::method<123>; break;
1469 case 124: *address = &TemplateTestFacility_StubClass::method<124>; break;
1470 case 125: *address = &TemplateTestFacility_StubClass::method<125>; break;
1471 case 126: *address = &TemplateTestFacility_StubClass::method<126>; break;
1472 case 127: *address = &TemplateTestFacility_StubClass::method<127>; break;
1473 default : BSLS_ASSERT_OPT(false);
1474 }
1475}
1476
1477template <class ALLOCATOR>
1478inline
1479void TemplateTestFacility::emplace(MethodPtr *address,
1480 int identifier,
1481 ALLOCATOR *allocator)
1482{
1483 emplace(address, identifier, bsl::allocator<MethodPtr>(allocator));
1484}
1485
1486// TBD: still working on this as part of C++11 project but should not affect
1487// component test drivers
1488template <class ALLOCATOR>
1489inline
1491 int identifier,
1492 ALLOCATOR allocator)
1493{
1494 BSLS_ASSERT_SAFE(identifier >= 0);
1495 BSLS_ASSERT_SAFE(identifier < 128);
1496
1497 EmplacableTestType::ArgType01 A01(identifier);
1511
1512 switch (identifier) {
1513 case 0: {
1515 } break;
1516 case 1: {
1518 allocator,
1519 address,
1521 } break;
1522 case 2: {
1524 allocator,
1525 address,
1528 } break;
1529 case 3: {
1531 allocator,
1532 address,
1536 } break;
1537 case 4: {
1539 allocator,
1540 address,
1545 } break;
1546 case 5: {
1548 allocator,
1549 address,
1555 } break;
1556 case 6: {
1558 allocator,
1559 address,
1566 } break;
1567 case 7: {
1569 allocator,
1570 address,
1578 } break;
1579 case 8: {
1581 allocator,
1582 address,
1591 } break;
1592 case 9: {
1594 allocator,
1595 address,
1605 } break;
1606 case 10: {
1608 allocator,
1609 address,
1620 } break;
1621 case 11: {
1623 allocator,
1624 address,
1636 } break;
1637 case 12: {
1639 allocator,
1640 address,
1653 } break;
1654 case 13: {
1656 allocator,
1657 address,
1671 } break;
1672 case 14: {
1674 allocator,
1675 address,
1690 } break;
1691 default: {
1693 allocator,
1694 address,
1696 }
1697 }
1698}
1699
1700template <class ALLOCATOR>
1701inline
1703 int identifier,
1704 ALLOCATOR *allocator)
1705{
1706 emplace(address,
1707 identifier,
1709}
1710
1711template <class ALLOCATOR>
1712inline
1714 int identifier,
1715 ALLOCATOR allocator)
1716{
1717 BSLS_ASSERT_SAFE(identifier >= 0);
1718 BSLS_ASSERT_SAFE(identifier < 128);
1719
1720 AllocEmplacableTestType::ArgType01 A01(identifier, allocator);
1721 AllocEmplacableTestType::ArgType02 A02( 20, allocator);
1722 AllocEmplacableTestType::ArgType03 A03( 23, allocator);
1723 AllocEmplacableTestType::ArgType04 A04( 44, allocator);
1724 AllocEmplacableTestType::ArgType05 A05( 66, allocator);
1725 AllocEmplacableTestType::ArgType06 A06( 176, allocator);
1726 AllocEmplacableTestType::ArgType07 A07( 878, allocator);
1727 AllocEmplacableTestType::ArgType08 A08( 8, allocator);
1728 AllocEmplacableTestType::ArgType09 A09( 912, allocator);
1729 AllocEmplacableTestType::ArgType10 A10( 102, allocator);
1730 AllocEmplacableTestType::ArgType11 A11( 111, allocator);
1731 AllocEmplacableTestType::ArgType12 A12( 333, allocator);
1732 AllocEmplacableTestType::ArgType13 A13( 712, allocator);
1733 AllocEmplacableTestType::ArgType14 A14(1414, allocator);
1734
1735 switch (identifier) {
1736 case 0: {
1738 } break;
1739 case 1: {
1741 allocator,
1742 address,
1744 } break;
1745 case 2: {
1747 allocator,
1748 address,
1751 } break;
1752 case 3: {
1754 allocator,
1755 address,
1759 } break;
1760 case 4: {
1762 allocator,
1763 address,
1768 } break;
1769 case 5: {
1771 allocator,
1772 address,
1778 } break;
1779 case 6: {
1781 allocator,
1782 address,
1789 } break;
1790 case 7: {
1792 allocator,
1793 address,
1801 } break;
1802 case 8: {
1804 allocator,
1805 address,
1814 } break;
1815 case 9: {
1817 allocator,
1818 address,
1828 } break;
1829 case 10: {
1831 allocator,
1832 address,
1843 } break;
1844 case 11: {
1846 allocator,
1847 address,
1859 } break;
1860 case 12: {
1862 allocator,
1863 address,
1876 } break;
1877 case 13: {
1879 allocator,
1880 address,
1894 } break;
1895 case 14: {
1897 allocator,
1898 address,
1913 } break;
1914 default: {
1916 allocator,
1917 address,
1919 }
1920 }
1921}
1922
1923template <class ALLOCATOR>
1924inline
1926 int identifier,
1927 ALLOCATOR *allocator)
1928{
1929 emplace(address,
1930 identifier,
1932}
1933
1934template <class TYPE>
1935inline
1937{
1938 bsls::Types::IntPtr result = reinterpret_cast<bsls::Types::IntPtr>(object);
1939 return static_cast<int>(result);
1940}
1941
1942template <class TYPE>
1943inline
1945{
1947 // The static assertion catches most improper use of calling this function
1948 // with an explicit instantiation: 'getIdentifier<TYPE>(obj)'. Calls to
1949 // this function should always rely on type deduction to determine 'TYPE'
1950 // and pick the correct overload for this template.
1951
1952 return static_cast<int>(object);
1953}
1954
1955inline
1956int TemplateTestFacility::getIdentifier(const char*const& object)
1957{
1958 return object ? atoi(object) : 0;
1959}
1960
1961template <class ALLOC>
1962inline
1964{
1965 return object.data();
1966}
1967
1968template <>
1969inline
1973{
1974 if (!ptr) {
1975 return 0; // RETURN
1976 }
1977
1979 return (object.*ptr)();
1980}
1981
1982template <>
1983inline
1984int TemplateTestFacility::getIdentifier<bsltf::UnionTestType>(
1985 const bsltf::UnionTestType& object)
1986{
1987 return object.data();
1988}
1989
1990template <>
1991inline
1992int TemplateTestFacility::getIdentifier<bsltf::SimpleTestType>(
1993 const bsltf::SimpleTestType& object)
1994{
1995 return object.data();
1996}
1997
1998template <>
1999inline
2000int TemplateTestFacility::getIdentifier<bsltf::AllocTestType>(
2001 const bsltf::AllocTestType& object)
2002{
2003 return object.data();
2004}
2005
2006template <>
2007inline
2008int TemplateTestFacility::getIdentifier<bsltf::NonOptionalAllocTestType>(
2009 const bsltf::NonOptionalAllocTestType& object)
2010{
2011 return object.data();
2012}
2013
2014template <>
2015inline
2016int TemplateTestFacility::getIdentifier<bsltf::MovableAllocTestType>(
2017 const bsltf::MovableAllocTestType& object)
2018{
2019 return object.data();
2020}
2021
2022template <>
2023inline
2024int TemplateTestFacility::getIdentifier<bsltf::MovableTestType>(
2025 const bsltf::MovableTestType& object)
2026{
2027 return object.data();
2028}
2029
2030template <>
2031inline
2032int TemplateTestFacility::getIdentifier<bsltf::MoveOnlyAllocTestType>(
2033 const bsltf::MoveOnlyAllocTestType& object)
2034{
2035 return object.data();
2036}
2037
2038template <>
2039inline
2040int TemplateTestFacility::getIdentifier<bsltf::BitwiseCopyableTestType>(
2041 const bsltf::BitwiseCopyableTestType& object)
2042{
2043 return object.data();
2044}
2045
2046template <>
2047inline
2048int TemplateTestFacility::getIdentifier<bsltf::BitwiseMoveableTestType>(
2049 const bsltf::BitwiseMoveableTestType& object)
2050{
2051 return object.data();
2052}
2053
2054template <>
2055inline
2056int TemplateTestFacility::getIdentifier<bsltf::AllocBitwiseMoveableTestType>(
2058{
2059 return object.data();
2060}
2061
2062template <>
2063inline
2064int TemplateTestFacility::getIdentifier<bsltf::NonTypicalOverloadsTestType>(
2066{
2067 return object.data();
2068}
2069
2070template <>
2071inline
2072int TemplateTestFacility::getIdentifier<bsltf::NonAssignableTestType>(
2073 const bsltf::NonAssignableTestType& object)
2074{
2075 return object.data();
2076}
2077
2078template <>
2079inline
2086
2087template <>
2088inline
2095
2096template <>
2097inline
2098int TemplateTestFacility::getIdentifier<bsltf::NonEqualComparableTestType>(
2100{
2101 return object.data();
2102}
2103
2104template <>
2105inline
2106int TemplateTestFacility::getIdentifier<bsltf::EmplacableTestType>(
2107 const bsltf::EmplacableTestType& object)
2108{
2109 BSLS_ASSERT_SAFE( 1 <= object.arg01() || 128 > object.arg01());
2110 BSLS_ASSERT_SAFE( 20 == object.arg02() || -1 == object.arg02());
2111 BSLS_ASSERT_SAFE( 23 == object.arg03() || -1 == object.arg03());
2112 BSLS_ASSERT_SAFE( 44 == object.arg04() || -1 == object.arg04());
2113 BSLS_ASSERT_SAFE( 66 == object.arg05() || -1 == object.arg05());
2114 BSLS_ASSERT_SAFE( 176 == object.arg06() || -1 == object.arg06());
2115 BSLS_ASSERT_SAFE( 878 == object.arg07() || -1 == object.arg07());
2116 BSLS_ASSERT_SAFE( 8 == object.arg08() || -1 == object.arg08());
2117 BSLS_ASSERT_SAFE( 912 == object.arg09() || -1 == object.arg09());
2118 BSLS_ASSERT_SAFE( 102 == object.arg10() || -1 == object.arg10());
2119 BSLS_ASSERT_SAFE( 111 == object.arg11() || -1 == object.arg11());
2120 BSLS_ASSERT_SAFE( 333 == object.arg12() || -1 == object.arg12());
2121 BSLS_ASSERT_SAFE( 712 == object.arg13() || -1 == object.arg13());
2122 BSLS_ASSERT_SAFE(1414 == object.arg14() || -1 == object.arg14());
2123
2124 return -1 == object.arg01() ? 0
2125 : -1 == object.arg02() ? object.arg01()
2126 : -1 == object.arg03() ? 2
2127 : -1 == object.arg04() ? 3
2128 : -1 == object.arg05() ? 4
2129 : -1 == object.arg06() ? 5
2130 : -1 == object.arg07() ? 6
2131 : -1 == object.arg08() ? 7
2132 : -1 == object.arg09() ? 8
2133 : -1 == object.arg10() ? 9
2134 : -1 == object.arg11() ? 10
2135 : -1 == object.arg12() ? 11
2136 : -1 == object.arg13() ? 12
2137 : -1 == object.arg14() ? 13
2138 : 14;
2139}
2140
2141template <>
2142inline
2143int TemplateTestFacility::getIdentifier<bsltf::AllocEmplacableTestType>(
2144 const bsltf::AllocEmplacableTestType& object)
2145{
2146 BSLS_ASSERT_SAFE( 1 == object.arg01() || -1 == object.arg01());
2147 BSLS_ASSERT_SAFE( 20 == object.arg02() || -1 == object.arg02());
2148 BSLS_ASSERT_SAFE( 23 == object.arg03() || -1 == object.arg03());
2149 BSLS_ASSERT_SAFE( 44 == object.arg04() || -1 == object.arg04());
2150 BSLS_ASSERT_SAFE( 66 == object.arg05() || -1 == object.arg05());
2151 BSLS_ASSERT_SAFE( 176 == object.arg06() || -1 == object.arg06());
2152 BSLS_ASSERT_SAFE( 878 == object.arg07() || -1 == object.arg07());
2153 BSLS_ASSERT_SAFE( 8 == object.arg08() || -1 == object.arg08());
2154 BSLS_ASSERT_SAFE( 912 == object.arg09() || -1 == object.arg09());
2155 BSLS_ASSERT_SAFE( 102 == object.arg10() || -1 == object.arg10());
2156 BSLS_ASSERT_SAFE( 111 == object.arg11() || -1 == object.arg11());
2157 BSLS_ASSERT_SAFE( 333 == object.arg12() || -1 == object.arg12());
2158 BSLS_ASSERT_SAFE( 712 == object.arg13() || -1 == object.arg13());
2159 BSLS_ASSERT_SAFE(1414 == object.arg14() || -1 == object.arg14());
2160
2161 return -1 == object.arg01() ? 0
2162 : -1 == object.arg02() ? 1
2163 : -1 == object.arg03() ? 2
2164 : -1 == object.arg04() ? 3
2165 : -1 == object.arg05() ? 4
2166 : -1 == object.arg06() ? 5
2167 : -1 == object.arg07() ? 6
2168 : -1 == object.arg08() ? 7
2169 : -1 == object.arg09() ? 8
2170 : -1 == object.arg10() ? 9
2171 : -1 == object.arg11() ? 10
2172 : -1 == object.arg12() ? 11
2173 : -1 == object.arg13() ? 12
2174 : -1 == object.arg14() ? 13
2175 : 14;
2176}
2177
2178template <>
2179inline
2186
2187template <class TYPE>
2190{
2191 return getMovedFrom(object);
2192}
2193
2194template <class TYPE>
2197{
2198 return getMovedInto(object);
2199}
2200
2201template <class TYPE>
2204{
2205 setMovedInto(object, value);
2206}
2207
2208// FREE FUNCTIONS
2209inline
2211{
2213}
2214
2215inline
2217{
2219}
2220
2221inline
2223{
2225}
2226
2227inline
2229{
2231}
2232
2233inline
2235{
2237}
2238
2239template <class ALLOC>
2240inline
2242{
2244}
2245
2246inline
2248{
2250}
2251
2252inline
2254{
2256}
2257
2258inline
2260{
2262}
2263
2264inline
2266{
2268}
2269
2270inline
2272{
2274}
2275
2276inline
2278{
2280}
2281
2282inline
2284{
2286}
2287
2288inline
2290{
2292}
2293
2294inline
2296{
2298}
2299
2300inline
2305
2306inline
2308{
2310}
2311
2312inline
2314{
2316}
2317
2318inline
2320{
2322}
2323
2324inline
2329
2330} // close package namespace
2331
2332
2333#endif
2334
2335// ----------------------------------------------------------------------------
2336// Copyright 2017 Bloomberg Finance L.P.
2337//
2338// Licensed under the Apache License, Version 2.0 (the "License");
2339// you may not use this file except in compliance with the License.
2340// You may obtain a copy of the License at
2341//
2342// http://www.apache.org/licenses/LICENSE-2.0
2343//
2344// Unless required by applicable law or agreed to in writing, software
2345// distributed under the License is distributed on an "AS IS" BASIS,
2346// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2347// See the License for the specific language governing permissions and
2348// limitations under the License.
2349// ----------------------------- END-OF-FILE ----------------------------------
2350
2351/** @} */
2352/** @} */
2353/** @} */
Definition bslma_bslallocator.h:580
static MallocFreeAllocator & singleton()
Definition bsltf_allocbitwisemoveabletesttype.h:136
Definition bsltf_allocemplacabletesttype.h:236
Definition bsltf_alloctesttype.h:149
Definition bsltf_bitwisecopyabletesttype.h:131
Definition bsltf_bitwisemoveabletesttype.h:131
Definition bsltf_emplacabletesttype.h:104
Definition bsltf_movablealloctesttype.h:153
Definition bsltf_movabletesttype.h:148
Definition bsltf_moveonlyalloctesttype.h:147
Definition bsltf_nonassignabletesttype.h:104
Definition bsltf_noncopyconstructibletesttype.h:105
int data() const
Return the value of the data attribute of this object.
Definition bsltf_noncopyconstructibletesttype.h:199
Definition bsltf_nondefaultconstructibletesttype.h:97
int data() const
Return the value of the data attribute of this object.
Definition bsltf_nondefaultconstructibletesttype.h:178
Definition bsltf_nonequalcomparabletesttype.h:103
int data() const
Return the value of the data attribute of this object.
Definition bsltf_nonequalcomparabletesttype.h:182
Definition bsltf_nonoptionalalloctesttype.h:139
Definition bsltf_nontypicaloverloadstesttype.h:114
Definition bsltf_simpletesttype.h:130
Definition bsltf_stdalloctesttype.h:164
Definition bsltf_templatetestfacility.h:608
static bool areNotEqual(const TYPE &lhs, const TYPE &rhs)
Definition bsltf_templatetestfacility.h:1159
static bool areEqual(const TYPE &lhs, const TYPE &rhs)
Definition bsltf_templatetestfacility.h:1151
Definition bsltf_templatetestfacility.h:594
int method()
Return the parameterized IDENTIFIER.
Definition bsltf_templatetestfacility.h:1140
Definition bsltf_wellbehavedmoveonlyalloctesttype.h:151
int data() const
Return the value of the data attribute of this object.
Definition bsltf_wellbehavedmoveonlyalloctesttype.h:296
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:229
#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 bsltf_allocargumenttype.h:92
void debugprint(const ArgumentType< N > &object)
Definition bsltf_argumenttype.h:551
MoveState::Enum getMovedInto(const AllocArgumentType< N > &object)
Return the move-into state of the specified object.
Definition bsltf_allocargumenttype.h:413
void setMovedInto(MovableTestType *object, MoveState::Enum value)
Definition bsltf_movabletesttype.h:306
MoveState::Enum getMovedFrom(const AllocArgumentType< N > &object)
Return the move-from state of the specified object.
Definition bsltf_allocargumenttype.h:406
static void construct(ALLOCATOR_TYPE &basicAllocator, ELEMENT_TYPE *elementAddr, Args &&... arguments)
Definition bslma_allocatortraits.h:1472
Definition bslmf_issame.h:146
static MovableRef< t_TYPE > move(t_TYPE &reference) BSLS_KEYWORD_NOEXCEPT
Definition bslmf_movableref.h:1060
std::ptrdiff_t IntPtr
Definition bsls_types.h:130
Enum
Definition bsltf_enumeratedtesttype.h:94
Enum
Enumeration of move state.
Definition bsltf_movestate.h:119
Definition bsltf_templatetestfacility.h:637
TemplateTestFacility_StubClass * ObjectPtr
Definition bsltf_templatetestfacility.h:650
static void emplace(unsigned char *address, int identifier, ALLOCATOR allocator)
static void emplace(TYPE *address, int identifier, ALLOCATOR allocator)
Definition bsltf_templatetestfacility.h:1199
int(TemplateTestFacility_StubClass::* MethodPtr)()
Definition bsltf_templatetestfacility.h:658
static bsltf::MoveState::Enum getMovedFromState(const TYPE &object)
static void emplace(unsigned char *address, int identifier, ALLOCATOR *allocator)
static int getIdentifier(const TYPE &object)
Definition bsltf_templatetestfacility.h:1944
static bsltf::MoveState::Enum getMovedIntoState(const TYPE &object)
static TYPE create(int identifier)
Definition bsltf_templatetestfacility.h:1188
static void setMovedIntoState(TYPE *object, bsltf::MoveState::Enum value)
Definition bsltf_templatetestfacility.h:2202
void(* FunctionPtr)()
This typedef is an alias for a pointer to a function pointer.
Definition bsltf_templatetestfacility.h:653
Definition bsls_objectbuffer.h:276
TYPE * address()
Definition bsls_objectbuffer.h:334
TYPE & object()
Definition bsls_objectbuffer.h:351
Definition bsltf_uniontesttype.h:107