[#BloombergLP-bslalg] = xref:BloombergLP.adoc[BloombergLP]::bslalg :relfileprefix: ../ :mrdocs: Namespace for low‐level algorithms and type traits used by BSL containers. == Types [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslalg/ArrayDestructionPrimitives.adoc[`ArrayDestructionPrimitives`] | This `struct` provides a namespace for a suite of utility functions that destroy arrays of elements of the parameterized type `TARGET_TYPE`. Depending on the traits of `TARGET_TYPE`, the destructor may be invoked, or not (optimized away by no‐op). | xref:BloombergLP/bslalg/ArrayPrimitives.adoc[`ArrayPrimitives`] | This `struct` provides a namespace for a suite of independent utility functions that operate on arrays of elements of parameterized type `TARGET_TYPE`. Depending on the traits of `TARGET_TYPE`, the default and copy constructors, destructor, assignment operators, etcetera may not be invoked, optimized away by no‐op or bit‐wise move or copy. | xref:BloombergLP/bslalg/ArrayPrimitives_CanBitwiseCopy.adoc[`ArrayPrimitives_CanBitwiseCopy`] | Metafunction that is `true` when `FROM_TYPE` and `TO_TYPE` are the same type (ignoring top‐level `const`) and that type is bit‐wise copyable. | xref:BloombergLP/bslalg/AutoArrayDestructor.adoc[`AutoArrayDestructor`] | This `class` provides a specialized proctor object that, upon destruction and unless the `release` method has been called, destroys the elements in a segment of an array of parameterized type `OBJECT_TYPE`. The elements destroyed are delimited by the "guarded" range `[ begin(), end() )]`. | xref:BloombergLP/bslalg/AutoArrayMoveDestructor.adoc[`AutoArrayMoveDestructor`] | This `class` provides a specialized proctor object that, upon destruction and unless the `release` method has been called, bit‐wise moves the elements in a segment of an array of parameterized `OBJECT_TYPE` back to some destination, and destroys some other elements in an adjacent segment of the same array. The elements destroyed are delimited by the range `[ begin(), middle() )]` and those moved to `destination()` and in the range `[ middle(), end() )]`. Note that, once constructed, `begin()` and `end()` remain fixed. As the guard advances, `middle()` and `destination()` move, reflecting the successful transfer of data between the moving range and the destination. | xref:BloombergLP/bslalg/AutoScalarDestructor.adoc[`AutoScalarDestructor`] | This `class` provides a specialized proctor object that, upon destruction and unless the `release` method is called, destroys the guarded object of the parameterized `OBJECT_TYPE`. | xref:BloombergLP/bslalg/BidirectionalLink.adoc[`BidirectionalLink`] | This POD‐like `class` describes a node suitable for use in a doubly‐ linked (bidirectional) list, holding the addresses of the preceding and succeeding nodes, either or both of which may be 0. This class is "POD‐like" to facilitate efficient allocation and use in the context of a container implementations. In order to meet the essential requirements of a POD type, this `class` does not declare a constructor or destructor. However its data members are private. It satisfies the requirements of a _trivial_ type and a _standard_ _layout_ type defined by the C++11 standard. Note that this type does not contain any "payload" member data: Clients creating a doubly‐linked list of data must define an appropriate node type that incorporates `BidirectionalLink` (generally via inheritance), and that holds the "value" of any data stored in that node. | xref:BloombergLP/bslalg/BidirectionalLinkListUtil.adoc[`BidirectionalLinkListUtil`] | This `struct` provides a namespace for utility functions that manipulate linked lists based on `bslalg::BidirectionalLink` nodes, including insertion, removal, and _splicing_. | xref:BloombergLP/bslalg/BidirectionalNode.adoc[`BidirectionalNode`] | This POD‐like `class` describes a node suitable for use in a doubly‐linked list of values of the template parameter type `VALUE`. This class is a "POD‐like" to facilitate efficient allocation and use in the context of a container implementation. In order to meet the essential requirements of a POD type, this `class` does not define a constructor or destructor. The manipulator, `value`, returns a modifiable reference to `d_value` so that it may be constructed in‐place by the appropriate `bsl::allocator_traits` object. | xref:BloombergLP/bslalg/ConstructorProxy.adoc[`ConstructorProxy`] | This class acts as a proxy for constructing and destroying an object of parameterized `OBJECT_TYPE`, where `OBJECT_TYPE` may or may not use a `bslma` allocator for supplying memory. The constructors for this proxy class take a `bslma::Allocator *`. If `OBJECT_TYPE` has the `bslma::UsesBslmaAllocator` trait declared, then the supplied allocator will be used to construct the proxied object. Otherwise, the allocator is ignored. | xref:BloombergLP/bslalg/ConstructorProxy_AllocatorType-08.adoc[`ConstructorProxy_AllocatorType`] | Metafunction to determine the allocator type for a specified template parameter `TYPE` using the specified template parater `AAMODEL` for constructors. This primary template yields a nested `type` of `bsl::polymorphic_allocator`, which is the most permisive type to use as a constructor parameter, and an `ArgType` allocator constructor argument that is a wrapper around `polymorphic_allocator` that tolerates being constructed with a null pointer. However, if `AAMODEL` is `AAModelNone` or `AAModelStl`, the allocator constructor argument is ignored and not passed to the proxied object. | xref:BloombergLP/bslalg/ConstructorProxy_PolymorphicAllocator.adoc[`ConstructorProxy_PolymorphicAllocator`] | Wrapper around `bsl::polymorphic_allocator` that can tolerate being constructed with a null pointer. | xref:BloombergLP/bslalg/ContainerBase.adoc[`ContainerBase`] | Allocator proxy class for STL‐style containers. Provides access to the allocator. Implements the entire STL allocator interface, redirecting allocation and deallocation calls to the proxied allocator. One of two possible base classes is chosen depending on whether `ALLOCATOR` is an empty class. | xref:BloombergLP/bslalg/ContainerBase_EmptyBase.adoc[`ContainerBase_EmptyBase`] | One of two possible base classes for `ContainerBase`. This class is for stateless allocators (i.e., that have size 0), including `std::allocator` (but not `bsl::allocator`). Provides access to the allocator. | xref:BloombergLP/bslalg/ContainerBase_NonEmptyBase.adoc[`ContainerBase_NonEmptyBase`] | One of two possible base classes for `ContainerBase`. This class should be used only for allocators with size > 0 (Inheritance from this type can cause ambiguous conversions and should be avoided or insulated.) | xref:BloombergLP/bslalg/DequeImpUtil.adoc[`DequeImpUtil`] | This `struct`, parameterized by the `VALUE_TYPE` and a `BLOCK_LENGTH`, provides the various parameters of the deque implementation. | xref:BloombergLP/bslalg/DequeIterator-0d.adoc[`DequeIterator`] | Implementation of a deque iterator, parameterized by the `VALUE_TYPE`, for a deque with the parameterized `BLOCK_LENGTH`, and suitable for use by the `bslstl::RandomAccessIterator` adapter. Note that `BLOCK_LENGTH` is the number of items of `VALUE_TYPE` within a block, not the size of a block in bytes. | xref:BloombergLP/bslalg/DequePrimitives-01.adoc[`DequePrimitives`] | This `struct` provides a namespace for a suite of utility functions that operate on deques parameterized by the `VALUE_TYPE` and `BLOCK_LENGTH`. Depending on the traits of `VALUE_TYPE`, the default and copy constructors, destructor, assignment operators, etcetera may not be invoked, and instead the operation can be optimized using a no‐op, bitwise move, or bitwise copy. | xref:BloombergLP/bslalg/DequePrimitives_DequeElementGuard.adoc[`DequePrimitives_DequeElementGuard`] | This `class` provides a specialized proctor object that, upon destruction and unless the `release` method has been called, destroys the elements in a segment of a deque of parameterized `VALUE_TYPE`. The elements destroyed are delimited by the "guarded" range `[d_begin .. d_end)]`. | xref:BloombergLP/bslalg/DequePrimitives_DequeEndpointProctor.adoc[`DequePrimitives_DequeEndpointProctor`] | This class implements a proctor that, upon destruction and unless its `release` method has previously been invoked, sets a deque endpoint (i.e., "start" or "finish" iterator) to a position within the deque. Both the endpoint and position are supplied at construction. See `emplaceAndMoveToBack` and `emplaceAndMoveToFront` for use cases. | xref:BloombergLP/bslalg/DequePrimitives_DequeMoveGuard.adoc[`DequePrimitives_DequeMoveGuard`] | This `class` provides a guard object that, upon destruction and unless the `release` method has been called, uses `moveBack` or `moveFront` to move the "guarded" range `[d_source_p .. d_source_p + d_size ‐ 1]` back to `[d_destination_p .. d_destination_p + d_size ‐1]`. | xref:BloombergLP/bslalg/DequePrimitives_ExternalDequeElementGuard.adoc[`DequePrimitives_ExternalDequeElementGuard`] | This `class` provides a specialized proctor object that, upon destruction and unless the `release` method has been called, destroys the elements in a segment of a `bsl::deque` of parameterized type `VALUE_TYPE`. The elements destroyed are delimited by the "guarded" range `[*d_begin .. *d_end)]`. Note that the range guarded by this `class` is dynamic and can be changed outside of this `class`. | xref:BloombergLP/bslalg/FunctorAdapter-09.adoc[`FunctorAdapter`] | This class provides a metafunction that defines an alias `Type` for the parameterized `CALLABLE_OBJECT`. `Type` is functor type that provides the same operation as the parameterized `CALLABLE_OBJECT`. Note that function pointers are supported through a specialization of this template. | xref:BloombergLP/bslalg/FunctorAdapter_FunctionPointer.adoc[`FunctorAdapter_FunctionPointer`] | This class provides a functor that delegates to the function referred to by a function pointer supplied on construction. Delegation is supported through the conversion operator, which implicitly returns a reference to the parameterized `FUNCTION_POINTER`. | xref:BloombergLP/bslalg/HasStlIterators-0e.adoc[`HasStlIterators`] | This class detects if the specified class `TYPE` has STL‐like iterators. If the class `TYPE` provides STL‐like iterators then `HasStlIterators<TYPE>::value == true`, and `HasStlIterators<TYPE>::value == false` otherwise. | xref:BloombergLP/bslalg/HasTrait.adoc[`HasTrait`] | This meta‐function evaluates to `bsl::true_type` if the (template parameter) `TYPE` has the (template parameter) `TRAIT`, and to `bsl::false_type` otherwise. | xref:BloombergLP/bslalg/HashTableAnchor.adoc[`HashTableAnchor`] | This complex constrained _in_‐_core_ (value‐semantic) attribute class characterizes the key data elements of a hash table. See the section information on the class attributes. Note that the class invariant is the identically the complex constraint of this component. | xref:BloombergLP/bslalg/HashTableBucket.adoc[`HashTableBucket`] | | xref:BloombergLP/bslalg/HashTableImpUtil.adoc[`HashTableImpUtil`] | This `struct` provides a namespace for a suite of utility functions for creating and manipulating a hash table. | xref:BloombergLP/bslalg/HashTableImpUtil_ExtractKeyResult.adoc[`HashTableImpUtil_ExtractKeyResult`] | Metafunction that deduces the return type of `KEY_CONFIG::extractKey`. | xref:BloombergLP/bslalg/HashUtil.adoc[`HashUtil`] | This `struct` provides a namespace for hash functions. | xref:BloombergLP/bslalg/NothrowMovableUtil.adoc[`NothrowMovableUtil`] | Namesapace for `NothrowMovableWrapper` traits and utilities. | xref:BloombergLP/bslalg/NothrowMovableUtil_Traits-04.adoc[`NothrowMovableUtil_Traits`] | Metafunction providing traits for `NothrowMovableWrapper` types. | xref:BloombergLP/bslalg/NothrowMovableWrapper-02.adoc[`NothrowMovableWrapper`] | An object of this type wraps a value of the specified `TYPE`, and provides no other functionality other than returning the wrapped object. The move constructor is guaranteed not to throw, even if the move constructor for `TYPE` has no such guarantee. The user is thus asserting that the move constructor for the wrapped object _will not_ throw, even if it is allowed to. Constraints: this class can be instantiated on object types only, i.e., not references, arrays, or function types (though function pointers are OK). | xref:BloombergLP/bslalg/NumericFormatterUtil.adoc[`NumericFormatterUtil`] | Namespace `struct` for free functions supporting `to_chars`. | xref:BloombergLP/bslalg/RangeCompare.adoc[`RangeCompare`] | This utility `struct` provides two static class methods, `equal` and `lexicographical`, for comparing two ranges of values. `equal` returns `true` if each element in one range has the same value as the corresponding element in the other range, and `false` otherwise. `lexicographical` returns 0 if the two ranges are equal, a positive value if the first range is greater than the second, and a negative value if the second range is greater than the first. A range is specified by a pair of beginning and ending iterators, with an optional length parameter. Additionally, an overload is provided for the `equal` class method that allows the end iterator for one range to be omitted. | xref:BloombergLP/bslalg/RbTreeAnchor.adoc[`RbTreeAnchor`] | An `RbTreeAnchor` provides the addresses of the first and root nodes of a binary search tree. An `RbTreeAnchor` is similar to an in‐core simply constrained (value‐semantic) attribute class, except that it does not supply equality‐comparison, copy‐construction, and copy‐assignment operations. Note that a node may not be copied because `sentinel` returns an address unique to each `RbTreeAnchor` object. | xref:BloombergLP/bslalg/RbTreeNode.adoc[`RbTreeNode`] | This POD‐like `class` describes a node suitable for use in a red‐black binary search tree, holding the addresses of the parent, left‐child, and right‐child nodes (any of which may be 0), as well as a "color" (red or black). This class is a "POD‐like" to facilitate efficient allocation and use in the context of a container implementation. In order to meet the essential requirements of a POD type, this `class` does not define a constructor or destructor. However its data members are private. Since this class will be aligned to a word boundary, a pointer type will be a multiple of 4. This class use this property to reduce its size by storing the color information in the least significant bit of the parent pointer. Note that this type does not contain any "payload" member data: Clients creating a red‐black binary search tree must define an appropriate node type that incorporates `RbTreeNode` (generally via inheritance), and that holds the "key" value and any associated data. | xref:BloombergLP/bslalg/RbTreeUtil.adoc[`RbTreeUtil`] | This `struct` provides a namespace for a suite of utility functions that operate on elements of type `RbTreeNode`. | xref:BloombergLP/bslalg/RbTreeUtilTreeProctor.adoc[`RbTreeUtilTreeProctor`] | This class implements a proctor that, unless `release` is called, invokes the parameterized `DELETER` on each node in the tree supplied at construction. | xref:BloombergLP/bslalg/RbTreeUtil_Validator.adoc[`RbTreeUtil_Validator`] | This `struct` provides a namespace for auxiliary functions used to validate a red‐black binary search tree. | xref:BloombergLP/bslalg/ScalarPrimitives.adoc[`ScalarPrimitives`] | This `struct` provides a namespace for a suite of utility functions that operate on elements of a parameterized type `TARGET_TYPE`. If any of the `...Construct` methods throws, then its target `address` is left uninitialized and there are no effects, unless otherwise mentioned in the documentation. | xref:BloombergLP/bslalg/SelectTrait.adoc[`SelectTrait`] | Select one trait out of several that the parameterized type `T` may possess. If `T` has the parameterized trait `TRAIT1`, then the nested `Type` is `TRAIT1`, else if `T` has an optionally parameterized `TRAIT2`, then `Type` is `TRAIT2`, etc. Also computes an integral selection constant and meta‐value. If `T` has none of the parameterized `TRAIT*`, then the nested `Type` is `TypeTraitNil`. | xref:BloombergLP/bslalg/SwapUtil.adoc[`SwapUtil`] | This class provides a namespace for the `swap` utility method. | xref:BloombergLP/bslalg/SynthThreeWayUtil.adoc[`SynthThreeWayUtil`] | "Exposition‐only" part of `bslstl_compare.h` | xref:BloombergLP/bslalg/TypeTraitBitwiseCopyable.adoc[`TypeTraitBitwiseCopyable`] | Objects of a type with this trait can be copied using `memcpy`. After such a bitwise copy, both the original and the copy are valid. Classes with this trait are assumed to have trivial (no‐op) destructors and are assumed to be bitwise moveable (see the `TypeTraitBitwiseMoveable` trait). Undefined behavior may result if this trait is assigned to a type that allocates memory or other resources, uses virtual inheritance, or places pointers to itself within other data structures. Also, objects of a type with this trait can be destroyed by a no‐op, i.e., not invoking the destructor, although it is safe to write zeros into the memory footprint of the object. | xref:BloombergLP/bslalg/TypeTraitBitwiseEqualityComparable.adoc[`TypeTraitBitwiseEqualityComparable`] | Objects of a type with this trait can be compared for equality using `memcmp`. If two objects compare equal, then `memcmp` returns 0, otherwise it returns non‐zero. Classes with this traits are assumed to have no padding and to be bit‐wise copyable (see the `TypeTraitBitwiseCopyable` trait). Undefined behavior may result if this trait is assigned to a type that does not have an `operator==` or whose `operator==` implementation may return different from comparing the footprints with `memcmp` . | xref:BloombergLP/bslalg/TypeTraitBitwiseMoveable.adoc[`TypeTraitBitwiseMoveable`] | Objects of a type with this trait can be "moved" from one memory location to another using `memmove` or `memcpy`. Although the result of such a bitwise copy is two copies of the same object, this trait only guarantees that one of the copies can be destroyed. The other copy must be considered invalid and its destructor must not be called. Most types, even those that contain pointers, are bitwise moveable. Undefined behavior may result if this trait is assigned to a types that contains pointers to its own internals, use virtual inheritance, or places pointers to itself within other data structures. | xref:BloombergLP/bslalg/TypeTraitHasPointerSemantics.adoc[`TypeTraitHasPointerSemantics`] | A type with this trait is said to have "pointer semantics". That is the type behaves as if it were a fundamental pointer type. The type must define(at a minimum) `operator*` and `operator‐>`. Note that simply providing the above operators does not imply that a type has pointer semantics. This trait is intended for "wrapper" types that behave as pointers. Some examples of such types include `std::auto_ptr`, and `bslma::ManagedPtr`. This trait is generally used by objects that invoke the wrapped type. | xref:BloombergLP/bslalg/TypeTraitHasStlIterators.adoc[`TypeTraitHasStlIterators`] | A `TYPE` with this trait defines (at minimum) the nested types `iterator` and `const_iterator` and the functions `begin()` and `end()` having the standard STL semantics. | xref:BloombergLP/bslalg/TypeTraitHasTrivialDefaultConstructor.adoc[`TypeTraitHasTrivialDefaultConstructor`] | A `TYPE` with this trait has a trivial default constructor. Objects of a type with this trait can be default‐initialized by simply writing zeros into the memory footprint of the object. Although it is possible for such a type not to be bitwise copyable, undefined behavior may result if this trait is assigned to such a type. (See the description of `TypeTraitBitwiseCopyable`.) | xref:BloombergLP/bslalg/TypeTraitNil.adoc[`TypeTraitNil`] | Nil trait ‐‐ every type has this trait. | xref:BloombergLP/bslalg/TypeTraitPair.adoc[`TypeTraitPair`] | A `TYPE` with this trait has two data members, `first` and `second` of types `T::first_type` and `T::second_type`, respectively. | xref:BloombergLP/bslalg/TypeTraitUsesBslmaAllocator.adoc[`TypeTraitUsesBslmaAllocator`] | A `TYPE` with this trait uses an allocator derived from `bslma::Allocator` to supply memory. See documentation on the `bslma_usesbslmaallocator` trait for the requirements on a `TYPE` that has this trait. |=== == Type Aliases [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslalg/ScalarDestructionPrimitives.adoc[`ScalarDestructionPrimitives`] | This alias is defined for backward compatibility. |=== == Enums [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslalg/_04enum.adoc[`Unnamed enum`] | These constants are used in the overloads below, when the last argument is of type 'bsl::integral_constant<int, N>', indicating that 'VALUE_TYPE' has the traits for which the enumerator equal to 'N' is named. Workaround for windows. The windows compiler refuses to recognize enum declarations within a class template. |=== == Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslalg/swap.adoc[`swap`] | Efficiently exchange the values of the specified `a` and `b` objects. This function provides the no‐throw exception‐safety guarantee. The behavior is undefined unless the two objects were created with the same allocator. | xref:BloombergLP/bslalg/operator_eq-0b.adoc[`operator==`] | Equality operators | xref:BloombergLP/bslalg/operator_not_eq-03.adoc[`operator!=`] | Inequality operators | xref:BloombergLP/bslalg/operator_3way-04.adoc[`operator<=>`] | Three‐way comparison operators |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#