BDE 4.0.0 Release¶
Schedule¶
The BDE team announces that the BDE 4.0.0 production release was completed on Monday, January 8, 2024.
Why a New Major Version?¶
This latest release contains important new features:
While those features are important, the major version number change also marks the capstone for the completion of series of features, collected under the umbrella project BDE 4.0 which have been delivered over the past three years.
Timeline of Major Releases¶
For some historical perspective, here is how BDE 4.0 fits in a timeline of major BDE releases:
2024
BDE 4.0
New model for Allocator-Aware components, optional, variant, C++20 support, better platform standard library integration
2017
BDE 3.2
Completed transition to open-source BDE libraries (bsl, bdl, bal).
2016
BDE 3.0
Begins adding C++11 support to BSL and transition to open-source libraries.
2010
BDE 2.0
bsl::
standard library factored into a separate package-group (bsl
). Removed STLPort.2004
BDE 1.0
Initial release. No published release notes.
The following sections explain the changes specifically in BDE 4.0. Further down, there is a more general description of the BDE 4.0 umbrella project.
BDE 4.0.0 Release Highlights¶
This release is a capstone on a collection of features intended to improve BDE’s standard conformance and interoperability with the platform standard library. These “BDE 4.0” features have been released as they were ready over the last 2 years.
This particular release contains the final set of BDE 4.0 library features:
An Updated Allocator Model¶
Note
A detailed specification for the new allocator model can be found in the white paper Making C++ Software Allocator Aware
BDE 4.0 introduces support for a new model for writing allocator-aware components,
documented in the white paper Making C++ Software Allocator Aware.
Historically, allocators were passed using bslma::Allocator *
, and types were marked
as allocator-aware using the proprietary type-trait bslma::UsesBslmaAllocator
.
Bloomberg has worked with the C++ standard committee to introduce pmr
memory allocators
into the C++ standard library, and this release aligns BDE’s support for allocators
with those since adopted by the standard.
Moving forward, we recommend allocators should be passed using bsl::allocator<>
and
types be marked as being allocator aware using typedef bsl::allocator<> allocator_type
.
This release introduces bsl::memory_resource
, and makes notable changes to
bslma_allocator.h
(bslma::Allocator
now inherits from bsl::memory_resource
)
New components (and standard headers) include:
bsl_memory_resource.h
bslma_aamodel
bslma_aatypeutil
bslma_allocatorutil
bslma_bslallocator
bslma_deallocatebytesproctor
bslma_deallocateobjectproctor
bslma_deleteobjectproctor
bslma_hasallocatortype
bslma_isstdallocator
bslma_memoryresource
bslma_polymorphicallocator
bslmf_allocatorargt
More support for writing allocator-aware types, including types that allow
writing code that operates with both the old and new model can be found in
the new utilities bslma::AATypeUtil
and bslma::AllocatorUtil
.
There is considerably more detail in the white paper Making C++ Software Allocator Aware.
New Type: bsl::variant
¶
Note
Details on bsl::variant
are in bsl::variant: An Allocator-Aware Discriminated Union.
BDE 4.0 introduces the header <bsl_variant.h>
, which contains an allocator-aware
implementation of the C++17 <variant>
header with select C++20 enhancements.
The type bsl::variant<T...>
is a discriminated union of the types T...
,
similar to bdlb::Variant<T...>
. The types T...
are known as
alternatives. For example, an object of type
bsl::variant<int, double, const char*>
can hold either an int
, or a
double
, or a const char*
, but only one of these alternatives at a time.
The bsl::variant
object also keeps track of which alternative is currently
active, so, for example, if the bsl::variant
object holds a double
object, then an attempt to retrieve the stored const char*
object will fail
by returning a null pointer or throwing an exception.
Forwarding Headers¶
Note
The detailed specification for forwarding headers can be found in Forwarding Headers in BSL
BDE 4.0 introduces a specification for rendering forwarding headers – that is,
a header containing only forward declarations for types in an associated component.
Forward declarations are often used to reduce compile time in instances where a
type is used in name only (avoiding the need to #include
the type’s header).
An example of a BDE-style forwarding header is bslma_allocator.fwd.h.
Complete set of BDE 4.0 Features¶
An Updated Allocator Model¶
BDE 4.0 introduces support for a new model for writing allocator-aware components,
documented in the white paper Making C++ Software Allocator Aware.
Historically, allocators were passed using bslma::Allocator *
, and types were marked
as allocator-aware using the proprietary type-trait bslma::UsesBslmaAllocator
.
Bloomberg has worked with the C++ standard committee to introduce pmr
memory allocators
into the C++ standard library, and this release aligns BDE’s support for allocators
with those since adopted by the standard.
Moving forward, we recommend allocators should be passed using bsl::allocator<>
and
types be marked as being allocator aware using typedef bsl::allocator<> allocator_type
.
This release introduces bsl::memory_resource
, and makes notable changes to
bslma_allocator.h
(bslma::Allocator
now inherits from bsl::memory_resource
)
More support for writing allocator-aware types, including types that allow
writing code that operates with both the old and new model can be found in
the new utilities bslma::AATypeUtil
and bslma::AllocatorUtil
.
There is considerably more detail in the white paper Making C++ Software Allocator Aware.
Note
More information on the new allocator model can be found in the white paper Making C++ Software Allocator Aware
Support for New Standard, Allocator-Aware, Vocabulary Types¶
BDE 4.0 introduces support for allocator-aware versions of two important vocabulary types in the C++ standard library,
bsl::optional (released in 2021) and bsl::variant These replace
the, now deprecated, legacy BDE types bdlb::NullableValue
and bdlb::Variant
.
In terms of compatibility, bdlb::NullableValue
now inherits from bsl::optional
, to enable interoperability between the
types. Unfortunately, the standard definition for variant
differs substantially from bdlb::Variant
(e.g., bdlb::Variant
has a “null” state), so
bsl::variant
and bdlb::Variant
are distinct types.
Improved Compatibility with the Platform Standard Library¶
One important goal was for BDE 4.0 to improve interoperability with the platform standard library. This included 3 discrete features:
Adopting bsl::string_view
as Vocabulary for Passing Strings¶
Strings are a quintessential vocabulary type (meaning strings are frequently passed
as parameters to functions). bsl::string_view
, which is an alias to
std::string_view
on platforms that support it, provides a means for
writing functions taking a string as a parameter that is agnostic to whether
the supplied string is an std::string
, bsl::string
, or C-string (const char *
).
Support for bsl::chrono
¶
BDE continues to recommend using the date and time types in bdlt
, but bsl::chrono
(an alias
to std::chrono
available only on platforms where it is supported) provides
a standard alternative. As part of BDE 4.0, we provided conversions, particularly between
chrono::duration
and bdlt::TimeInterval
, and updated important concurrency APIs (bslmt
types
like bslmt::Condition
, bdlmt::EventScheduler
, bdlmt::Throttle
).
These changes are detailed in the document: bsl::chrono Integration with bsl and bdl.
A component-by-component Review of the BDE Libraries¶
The most time-consuming piece of BDE 4.0 was a component-by-component review
of the BDE libraries to make adjustments to allow for existing APIs
to work more seamlessly with the platform standard library
(e.g., using string_view
where appropriate, or providing
overloads for functions taking a bsl::vector
to use std::vector
)
Support for C++20¶
BDE has been enhanced to support C++20 library features, which will become available to most users once the production build base migrates to C++20.
The most obvious BSL features include the library and platform detection macros, support for the spaceship operator for BSL containers,
and a implementation of bsl::stop_token
that supports C++03. Additional detail is provided in the article
BSL Support for C++20.
A couple of additions planned for 2024:
bsl::format
support forbsl::string
, and compatible formatters for important vocabulary types.(Non-standard) utilities to support extract and merge operations for associative containers.
BDE 4.0 Work that Remains¶
There are a couple of non-library aspects of BDE 4.0 that will be completed in the next few months:
Update the BDE documentation standard to better support IDEs and other tools.
We are are currently reviewing a set of`proposed changes to BDE’s documentation format. Primarily moving documentation above the function signature, and using standard markdown.
Using GoogleTest for unit-tests.
BDE is adopting GoogleTest for unit-tests in at least one library. This means applying BDE’s rigorous testing methodology using a more standard set of unit-test rendering conventions. This will hopefully lead to a white-paper describing BDE’s testing methodology, which is agnostic to the test-framework (and even the programming langauge) being used.
Fixed Issues:¶
Summary |
---|
Update the BDE Allocator Model page to support move semantics and noexcept |
add an erase_if(key, predicate) to bdlcc::StripedUnorderedContainerImpl |
SOW19-D4-D7 Numerous AA facilities for BSL |
Remove bdldfp_decimal.h from bdld_datum.h |
Create bsl::variant an allocator aware variant type |
‘bsl::string_view’ is implicitly convertible to ‘bsl::string’ under Visual Studio |
‘bdls::FilesystemUtil::createTemporaryDirectory’ provokes to erroneously use it with ‘bdls::Filesyst… |
SAFE mode triggers a stringop-overflow warning at -O3 with GCC 11 |
BALL truncates 64 bit integer attributes |
Document compiler version check macros as for-testing-only |
reduce bde repo nb test driver warnings |
clean bde repo of nightly build test driver warnings |
Fix bdldfp_decimal.fwd.t.cpp breakage |
clean bde repo test driver warnings |
Optimize sim_cpp11_features.pl for perl 5.16 when handling huge header |
reduce bde repo nb warnings |
Runtime test failures for allocators |
Update bslma_bslallocator to use BSLS_DEPRECATE_FEATURE |
Add deprecated allocate() accessor to bslstl::basic_string |