BDE 3.117.0 Release

Schedule

  • The BDE team announces that the BDE 3.117.0 production release was completed on Monday, May 1, 2023.

BDE 3.117.0 Highlights

New Allocator Utilities

In preparation for upcoming modernization of our tools for writing Allocator Aware (AA) classes, we are releasing a set of allocator-related utilities and making some needed changes to bslma::UsesBslmaAllocator. Client code in DPKG/ROBO has already been adjusted to work correctly with these forward-looking changes, but clients outside of that ecosystem might need to review the workarounds suggested below.

Note that these new facilities are not yet recommended for client use. They will be promoted as part of a future BDE release and explained in a white-paper on writing allocator aware software that will be published at the same time.

Potentially Breaking Change in bslma::UsesBslmaAllocator

The bslma::UsesBslmaAllocator trait will now identify types that have a nested T::allocator_type type alias that is convertible from bslma::Allocator * as having the trait. This impacts any type which does the following:

  1. Inherits publicly from an AA type.

  2. Is not fully AA itself — i.e., it does not define the appropriate additional constructors taking allocator arguments.

  3. Is used in a context where being identified as AA but not actually meeting the requirements of being AA causes issues, such as being put in a bsl container.

To work around this, any such type should make allocator_type an alias for void, overriding the inherited alias from its base class. See below for more details.

New component, bslma_aamodel

This new component defines four models for Allocator Aware (AA) types: pmr-AA, bsl-AA, and legacy-AA, and STL-AA. Two metafunctions, AAModel<TYPE> and AAModelIsSupported<TYPE, MODEL> allow AA code to dispatch to the correct handling of types with different AA models, as well as non-AA types These metafunctions are typically used internally within the new bsl facilities and are not needed by most developers, even those creating AA classes.

New component, bslma_aatypeutil

This new component provides a number of utility functions for getting the allocator from an AA object in a mostly model-agnostic way. The developer of an AA class containing subobjects of AA type would use bslma::AATypeUtil::getAllocatorFromSubobject to retrieve an the allocator from one of those subobjects, even if the subobject uses a different AA model than the container class. bslma::AATypeUtil::getAdaptedAllocator returns the allocator from an object in the most interoperable format available.

New component, bslma_allocatorutil

This new component provides a function bslma::AllocatorUtil::adapt that converts an allocator into the most interoperable format available. If you need to convert between bslma::Allocator * and bsl:allocator, this function allows you to do that without losing information. It is especially useful in generic code where the allocator types you are converting between are not known in advance.

bslma::UsesBslmaAllocator enhancements

The bslma::UsesBslmaAllocator type trait has been enhanced in two ways:

  1. If a type T can be constructed (converted) implicitly from bslma::Allocator *, then a warning is generated for compilers that support deprecation warnings. The correct way to label T as AA is either to declare BSLMF_NESTED_TRAIT_DECLARATION(T, bslma::UsesBslmaAllocator) within class T or specialize UsesBslmaAllocator<T> within namespace BloombergLP::bslma. A constructor having a single bslma::Allocator * parameter should be declared explicit except in the rare situation where implicit construction from bslma::Allocator * is desirable.

  2. If, for a type T, there exists a nested T::allocator_type that is convertible from bslma::Allocator *, UsesBslmaAllocator<T> will automatically be true. This new features simplifies the definition of bsl-AA types, which must already declare allocator_type.

Note item 2 above means that inheriting from a class that defines allocator_type will implicitly make UsesBslmaAllocator true for the derived class, whether or not it has the correct AA constructors:

class BslAAClass {
  public:
    typedef bsl::allocator<char> allocator_type;

    explicit BslAAClass(const allocator_type& alloc = allocator_type());
    BslAAClass(const BslAAClass&     other,
               const allocator_type& alloc = allocator_type());
};

// Automatically detected from 'allocator_type'
BSLMF_ASSERT(bslma::UsesBslmaAllocator<BslAAClass>);

class NonAAClass : public BslAAClass {
  public:
    NonAAClass();
    NonAAClass(const NonAAClass& other);
};

// Error: 'NonAAClass' incorrectly deduced to be AA.
BSLMF_ASSERT(! bslma::UsesBslmaAllocator<NonAAClass>);

To suppress this behavior, override allocator_type as an alias for void:

class NonAAClass : public BslAAClass {
  public:
    typedef void allocator_type;  // Not an AA class

    NonAAClass();
    NonAAClass(const NonAAClass& other);
};

// OK, 'NonAAClass' no longer deduced as AA
BSLMF_ASSERT(! bslma::UsesBslmaAllocator<NonAAClass>);

C++20 Library Features

For compilers that support the 3-way comparison operator <=>, added support for the following types:

  • bsl::map

  • bsl::optional

  • bsl::pair

  • bsl::queue

  • bsl::stack

For libraries that meet the BSL C++20 library baseline implementation, provided bsl aliases for the following types in the <utility> header:

  • std::cmp_equal

  • std::cmp_not_equal

  • std::cmp_less

  • std::cmp_greater

  • std::cmp_less_equal

  • std::cmp_greater_equal

Compiler Feature Macros Deprecation

The macros BSLS_KEYWORD_CONSTEXPR_MEMBER and BSLS_KEYWORD_INLINE_CONSTEXPR have been deprecated, and extra documentation of correct usage of the various macros for keyword constexpr has been added to component bsls_keyword. In particular, current BSLS_KEYWORD_INLINE_CONSTEXPR usage should be reconsidered, as it is prone to undiagnosed Undefined Behavior because of the differences between internal linkage and external linkage in different versions of C++.

New Component: bdlf_noop

Introducing component bdlf_noop, providing class template bdlf::NoOp, which does nothing. When using an interface which requires a callable object, you can provide a callable which canonically does nothing (no matter the number or type of parameters) using this component. See bdlf_noop for more information.

Better STL/Google Mock support for bdljsn::JsonArray

Added type names to meet the C++20 Container requirements into JsonArray and JsonObject because they are required by some Google Mock matchers.

Fixed DRQSs:

Summary

SOW19-D2 BSL Allocator Model facilities in BDE

Provide bdlf_noop component

ninja: error: build.ninja:13881: multiple rules generate

C++20 work: Add <bsl_stop_token.h> header and alias standard entities

C++20 work: Add aliases to <bsl_utility.h>

C++20 work: Remove the ‘operator!=’ from the unordered associative containers

C++20 work: Add the ‘operator<=>’ to the ‘bslstl::map’

C++20 work: Add the ‘operator<=>’ to the ‘bslstl::optional’

C++20 work: Add the ‘operator<=>’ to the ‘bslstl::pair’

C++20 work: Add the ‘operator<=>’ to the ‘bslstl::queue’

C++20 work: Add the ‘operator<=>’ to the ‘bslstl::stack’

enhance BSLS keywords for constexpr

BBS build system: missing dependency resolution on Windows.

Merge fallback enumerators into bde

Accessing an array out of bounds in ‘bslim_gtestutil’ test driver

Make bdljsn::JsonArray more STL-containery

Cannot compile bsls_libraryfeatures.cpp on MacOS Ventura

baljsn_datumutil: Fix the test.

Fix JsonObject::insert SFINAE on Sun