Skip to content

BDE 2.24.1 Release Notes

Mike Verschell edited this page Oct 12, 2015 · 3 revisions

09/25/2015 BDE 2.24.1 Release Notes

BDE 2.24.1 Release

New: bslmf_movableref

This component defines templates for class and utility functions that provide C++11 move semantics in both C++03 and C++11 without conditional compilation by the client. The class template bslmf::MovableRef is a special reference wrapper in C++03 that supports excplicit move semantics with the utility bslmf::MovableRefUtil::move. In C++11 builds, these calls will use rvalue references, and so also allow implicit moves from temporary objects/return values. Note that for these semantics to work correctly, bslmf::MovableRef objects should always be passed by value.

Example:

template <class TYPE>
class MovablePointer {
    TYPE *d_target_p;

 private:
   MovablePointer(const MovablePointer&);
   MovablePointer& operator=(const MovablePointer&);
       // Make the copy operations inaccessible.

 public:
   MovablePointer(TYPE *ptr = 0) : d_target_p(ptr) {}
       // Take ownership of the specified `ptr`.

   MovablePointer(bslmf::MovableRef<MovablePointer> other)
       // Transfer ownership of the pointer managed by the specified
       // `other`.
   : d_target_p(bslmf::MovableRefUtil::access(other).d_target_p)
   {
       bslmf::MovableRefUtil::access(other).d_target_p = 0;
   }

   ~MovablePointer() { delete d_target_p; }
       // Delete the pointer managed by this object.

   MovablePointer& operator=(const MovablePointer& rhs);
       // Transfer ownership of the pointer managed by the specified
       // `other`.
   {
       MovablePointer temp(bslmf::MovableRefUtil::move(*this);
       bsl::swap(d_target_p, bslmf::MovableRefUtil::access(other).d_target_p);
   }
};

int main() {
   MovablePointer<int> x(new int(5));
   MovablePointer<int> y;
   y = bslmf::MovableRefUtil::move(x);
}

C++11 Forwarding Headers

Developers working in a C++11 environment now have access to many C++11 headers in the bsl namespace. Note that <type_traits> and <forward_list> are not yet available. The existing BDE type traits in the bslmf package remain available, including several implementation of standard traits in the bsl namespace, and these continue to be supported in C++03. Also note that these new headers will not compile if the appropriate C++11 header is not provided by the platform.

bsl_cstdint.h

The types provided by <cstdint> (e.g., int32_t, uint64_t) are now available in the bsl namespace by including bsl_cstdint.h. This header should work on all platforms, including in C++03 builds, and regardless of whether the underlying platform supplies <stdint.h>.

bsl::to_string

C++11 utility functions for converting numeric types to strings have been added to bsl::string. Note that these functions specified by the C++11 standard (but implemented for our C++03 library) will always return strings using the default allocator. Similarly, the C++11 functions to parse strings to numeric types are now available. All functions may be accessed through the <bsl_string.h> header.

bsl::enable_shared_from_this

The C++11 Standard type bsl::enable_shared_from_this is now available via bsl_memory.h. Objects of types that derive from bsl::enable_shared_from_this inherit a shared_from_this method. When such objects are held by bsl::shared_ptr, the shared_from_this method returns that shared pointer. If the object of the derived type is not held by a shared pointer, the behavior of shared_from_this is undefined.

bdlc_packedintarray

The class template, bldc::PackedIntArray, provides a space-efficient, dynamic array for integer types. For example, if one has such an array of int values, but all of the current values are of small magnitude (e.g., [0 .. 100]), the array might store the value in char-sized elements, but adopt a different internal storage strategy should a value larger than 127 be placed into the array.

bdldfp::DecimalConvertUtil Performance Improvements

The performance of two of the functions of bdldfp::DecimalConvertUtil have been improved:

  • decimal32FromDouble(double value)
  • decimal64FromDouble(double value)

The enhancements are effective when value has a magnitude less than 1E6. In that range, users can expect a manyfold improvement compared to previous releases. Outside of that range, users should expect no performance change (neither better nor worse).

bsls::TimeInterval ADL Fix

The operator<< of bsls::TimeInterval has been modified to work with generalized streaming facilities such as that featured in GTest.