Quick Links:

bal | bbl | bdl | bsl

Namespaces

Component bsltf_simpletesttype
[Package bsltf]

Provide a non-allocating test class without type traits. More...

Namespaces

namespace  bsltf

Detailed Description

Outline
Purpose:
Provide a non-allocating test class without type traits.
Classes:
bsltf::SimpleTestType non-allocating test class without type traits
See also:
Component bsltf_templatetestfacility
Description:
This component provides a single, unconstrained in-core (value-semantic) attribute class, SimpleTestType, that does not take an allocator nor define any type traits. SimpleTestType can be used during testing as the parameterized type of a class templates to ensure classes with the similar properties will function correctly. Note that this is particular valuable when testing a container template that supports different types of contained elements.
Attributes:
  Name                Type         Default
  ------------------  -----------  -------
  data                int          0
  • data: representation of the class value
Usage:
This section illustrates intended use of this component.
Example 1: Printing the Supported Traits:
Suppose we wanted to print the supported traits of this test type.
First, we create a function template printTypeTraits with a parameterized TYPE:
  template <class TYPE>
  void printTypeTraits()
      // Prints the traits of the parameterized 'TYPE' to the console.
  {
      if (bslma::UsesBslmaAllocator<TYPE>::value) {
          printf("Type defines bslma::UsesBslmaAllocator.\n");
      }
      else {
          printf(
               "Type does not define bslma::UsesBslmaAllocator.\n");
      }

      if (bslmf::IsBitwiseMoveable<TYPE>::value) {
          printf("Type defines bslmf::IsBitwiseMoveable.\n");
      }
      else {
          printf("Type does not define bslmf::IsBitwiseMoveable.\n");
      }
  }
Now, we invoke the printTypeTraits function template using SimpleTestType as the parameterized TYPE:
  printTypeTraits<SimpleTestType>();
Finally, we observe the console output:
  Type does not define bslma::UsesBslmaAllocator.
  Type does not define bslmf::IsBitwiseMoveable.