BDE 4.18.0 Release¶
Schedule¶
The BDE team announces that the BDE 4.18.0 production release was completed on Monday, Dec 16th, 2024.
BDE 4.18.0 Release Highlights¶
New Transparent Hasher Tailored for Strings: bdlb::TransparentStringHash¶
This release introduces the component bdlb::TransparentStringHash that
provides a transparent hash function that is specifically tailored to be used
with bsl::string keys.
A transparent hash function combined with using a transparent comparator allows
to avoid unnecessary conversions when looking up a key in unordered containers.
The most common use case is to avoid constructing a bsl::string when
looking up a string key represented by a const char * or
bsl::string_view. Without transparent hash and comparator, looking up a
const char * in a bsl::unordered_set<bsl::string> would incur a
conversion to bsl::string and possibly an unnecessary allocation.
Furthermore, attempting to look up a bsl::string_view fails to compile
since there is no implicit conversion from bsl::string_view to
bsl::string:
bsl::unordered_set<bsl::string> set{"hello", "goodbye"};
assert(set.contains("hello")); // Passes, but creates a temporary ``bsl::string``!
assert(set.contains(bsl::string_view("hello"))); // Does not compile - no implicit conversion!
Although using bdlb::TransparentHash and bdlb::TransparentEqualTo
allows to look up a bsl::string_view and removes the unnecessary
conversion, it comes with a surprising result where strings seemingly having
the same value are no longer found in the set:
bsl::unordered_set<bsl::string,
bdlb::TransparentHash,
bdlb::TransparentEqualTo> set{"hello", "goodbye"};
assert(set.contains("hello")); // No allocation, assertion FAILS!
assert(set.contains(bsl::string_view("hello"))); // No allocation, assertion PASSES.
This behavior is due to the default hasher, to which bdlb::TransparentHash
delegates, not treating const char * as a string, but rather as a raw
pointer, hashing the pointer value itself. With
bdlb::TransparentStringHash, however, const char * is treated as a
C-style string and is hashed accordingly, producing the expected result:
bsl::unordered_set<bsl::string,
bdlb::TransparentStringHash,
bdlb::TransparentEqualTo> set{"hello", "goodbye"};
assert(set.contains("hello")); // No allocation, assertion PASSES.
assert(set.contains(bsl::string_view("hello"))); // No allocation, assertion PASSES.
bslim::Printer Now Supports Tuples¶
This release adds support to bslim::Printer for printing objects of type
bsl::tuple, provided that each element type can be printed using
bslim::Printer. For example:
bsl::tuple<int, const char*, double> t(1, "two", 3.14);
bslim::Printer p(&bsl::cout, 0, -1);
p.printAttribute("tuple", t);
will output:
tuple = [ 1 "two" 3.14 ]
Note that bsl::tuple is an alias to std::tuple.
Fixed DRQSs:¶
Summary |
|---|
bdlt::Datetime::add*IfValid – internal over/underflow undermines wide contracts |
Add support for Linux ARM64 - fix tests |
Support bsl::tuple in bslim::Printer |
bdlde_base64-en-de-coderoptions documentation |
please correct/reduce bdlcc_deque case 15 intermittent issue |
Backport some C++20 type traits |
Add a release method to TempDirectoryGuard |
Add bdlcc::TimeQueue::removeIf w/ predicate |
Transparent Comparators For String |
Restore comments regarding key construction in map |
Fix ryu build for cmake_build.py |
Fix build error in bslmf_unwrapreference |