Quick Links:

bal | bbl | bdl | bsl

Namespaces | Typedefs

Component bsls_types
[Package bsls]

Provide a consistent interface for platform-dependent types. More...

Namespaces

namespace  bsls

Typedefs

typedef bsls::Types bsls_Types

Detailed Description

Outline
Purpose:
Provide a consistent interface for platform-dependent types.
Classes:
bsls::Types namespace for platform-neutral type names
Description:
This component provides a namespace for a set of typedefs that provide a stable, portable interface to platform-dependent types. In particular, this component supplies portable typenames for signed and unsigned 64-bit integers (bsls::Types::Int64 and bsls::Types::Uint64, respectively), as well as the preferred integral type denoting the number of elements in a container, and the number of bytes in a single block of memory supplied by an allocator (bsls::Types::size_type).
Usage:
The following illustrates how some of the types supplied by this component might be used.
bsls::Types::Int64 and bsls::Types::Uint64 identify the preferred fundamental types denoting signed and unsigned 64-bit integers, respectively:
  bsls::Types::Uint64 stimulus = 787000000000ULL;
Clients can use these types in the same way as an int. Clients can also mix usage with other fundamental integral types:
  bsls::Types::Uint64 nationalDebt = 1000000000000ULL;
  nationalDebt += stimulus;

  unsigned int deficitReduction = 1000000000;
  nationalDebt -= deficitReduction;

  std::cout << "National Debt Level: " << nationalDebt << std::endl;
bsls::Types::size_type identifies the preferred integral type denoting the number of elements in a container, and the number of bytes in a single block of memory supplied by an allocator. For example, a typical use is as a typedef in an STL container:
  class vector {

      // ...

    public:
      typedef bsls::Types::size_type size_type;

      // ...
  };
Note that Standard Library facilities that work with numeric types can be used with bsls::Types as well. For example, the following code finds out some facts about bsls::Types::Int64 in a platform-independent way:
  std::cout << "Min Int64 value: "
            << std::numeric_limits<bsls::Types::Int64>::min() << std::endl
            << "Max Int64 value: "
            << std::numeric_limits<bsls::Types::Int64>::max() << std::endl;

Typedef Documentation