BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsls_types

Typedefs

typedef bsls::Types bsls_Types
 This alias is defined for backward compatibility.
 

Detailed Description

Outline

Purpose

Provide a consistent interface for platform-dependent types.

Classes

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;
unsigned long long Uint64
Definition bsls_types.h:137

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;
// ...
};
std::size_t size_type
Definition bsls_types.h:124

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

◆ bsls_Types