Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

pilfer

Indicate that an object t may be pilfered from.

Synopsis

Defined in header <boost/json/pilfer.hpp>

template<
    class T>
auto
pilfer(
    T&& t);
Description

A pilfer operation is the construction of a new object of type T from an existing object t. After the construction, the only valid operation on the pilfered-from object is destruction. This permits optimizations beyond those available for a move-construction, as the pilfered-from object is not required to be in a "usable" state.

This is used similarly to std::move.

Example

A pilfer constructor accepts a single argument of type pilfered and throws nothing:

struct T
{
    T( pilfered<T> ) noexcept;
};

Pilfer construction is performed using pilfer :

{
    T t1;                       // default construction
    T t2( pilfer( t1 ) );       // pilfer-construct from t1

    // At this point, t1 may only be destroyed
}
See Also

pilfered, is_pilfer_constructible, Valueless Variants Considered Harmful

Convenience header <boost/json.hpp>


PrevUpHomeNext