BDE 3.122.0 Release¶
Schedule¶
The BDE team announces that the BDE 3.122.0 production release was completed on Monday, July 31, 2023.
BDE 3.122.0 Highlights¶
bsl::string
Has resize_and_overwrite
Method¶
The bsl::string
class now provides the resize_and_overwrite
method
– a C++23 feature – that allows one to avoid the wasted effort of zero
filling string contents (as is done by the classic resize
) when those
positions are about to be overwritten.
Consider the function loadFromIstream
that adjusts the size of the
output
string to the new size (by resize
) and then deposits data from
the input
stream to the available space (by read
):
void loadFromIstream(bsl::string *output,
bsl::istream& input,
bsl::streamsize count)
// Set the value of the specified 'output' string to the next specified
// 'count' bytes from the specified 'input' stream. The behavior is
// undefined unless ...
{
// Defensive programming checks here...
output->resize(count);
// If 'output' is initially empty, we could:
// assert(*output == bsl::string(count, '\0'));
input.read(output->data(), count);
}
Assuming output
is initially empty, it consists of count
'\0'
characters between the return from resize
until it is overwritten by the
call to read
. Creation of that artifact is of no use here and represents
wasted work.
Alternatively:
{
// Defensive programming checks here...
auto populator = [ &input ](char *dst, size_t srcSize) {
input.read(dst, srcSize);
return input.gcount(); // String size set to actual input count.
};
output->resize_and_overwrite(count, populator);
// ^^^^^^^^^^^^^^
}
Now, the output
string is never set to '\0'
characters.
bdlf::BindUtil::bind
Correctly Handles MovableRef
Arguments¶
BDE 3.122.0 fixes the behavior of bdlf::BindUtil::bind
when it is passed
MovableRef
and rvalue reference arguments. Prior to this release, in
C++03, passing a MovableRef
to bdlf::BindUtil::bind
would result in
the bdlf::Bind
object storing a pointer to the passed object instead of
move-constructing its copy, which would often result in a dangling pointer:
#include <bdlf_bind.h>
#include <bsl_functional.h>
#include <bsl_string.h>
using namespace BloombergLP;
int f(const bsl::string& s)
{
return s.size();
}
int main()
{
bsl::function<int()> func;
{
bsl::string s("abc");
func = bdlf::BindUtil::bind(&f, bslmf::MovableRefUtil::move(s));
// binds a pointer in C++03
}
return func();
// Pre-3.122.0': 'func' dereferences a dangling pointer!
// Now : 'func' gets a copy, even via *move*, so no problem.
}
In C++11 and later, the bdlf::Bind
object would store a copy of the
argument, but would not move-construct it, resulting in an unnecessary copy.
As of BDE 3.122.0, this code behaves as expected in all C++ versions: the
bdlf::Bind
object will store a move-constructed copy of the argument
supplied to the call to bdlf::BindUtil::bind
.
Other New Features¶
The
balcl::CommandLine
class now has additionalprintUsage
overloads that allow the user to explicity specify the task’s name.The
bdlb::NullableAllocatedValue
class now has small-object optimization.The
bslstl_inplace
component has added tag typesbsl::in_place_type_t
andbsl::in_place_index_t
.
Fixed DRQSs:¶
Summary |
---|
bdlf_bind: confusion with bslmf::MovableRef<T> args |
C++20 work: Add aliases to <bslstl_iterator.h> |
C++20 work: Add the ‘starts_with’ and the ‘ends_with’ methods to the ‘bslstl::basic_string_view’ |
Fix issue in bdlde_quotedprintableencoder.t |
Benchmark new ‘bdlb::NumericParseUtil:parseDouble’ |
Provide C++23 bsl::string::resize_and_overwrite |
balcl::Commadline optional ‘taskName’ argument for printUsage |
Please add a small-object optimization to bdlb::NullableAllocatedValue |
bsl::span usage produces warning in Sun compilation |
Please validate reference support for Sun Studio 12.6 for c++11 and above. |
reduce bde nb test driver compiler warnings for gcc-10 |
BDE: fix bslstl_string_test failure for CC 5.12.6 |
BDE: fix bslstl_array failure for CC 5.12.6 |
reduce bdl nb issues 20230711 |
reduce bsl nightly build issues 20230711 |
Add bsl::in_place_type and bsl::in_place_index |
bslmf_isnothrowswappable.h gcc warnings on manual builds |
reduce bal nb compile issues 20230712 |
reduce bal nb warnings 20230713 |
Fix bdlde_charconvertutf16.cpp to use consistent compiler feature for u16string |
reduce bal nb warnings 20230714 |
normalize use of // for testing only on includes in bde |
Cycle Removal: ball: Replace FileObserver2 in ball_log.t.cpp |
Cycle Removal: bdlb: Remove transparent[hash|equalto] usage example cycle |
Cycle Removal: bslmf:bslmf_isnothrowmoveconstructible test use of movableref |
Cycle Removal: bslmt: Remove cycles related to bslmt_testutil.t.cpp |
Cycle removal: bsls: Remove bsls_stackaddressutil dependency on SystemTime |
Cycle Removal: bslstl: bslstl_iterator.t.cpp remove cyclic dependency on bslstl_set |
Cycle Removal: bslstl: Remove stringview.t.cpp dependency on bslstl_map |
Cycle Removal: bslmt: Remove cycle with bslstl_ostream and osyncstream |