...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Indicate that an object t
may be pilfered from.
Defined in header <boost/json/pilfer.hpp>
template< class T> auto pilfer( T&& t);
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
.
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 }
pilfered
,
is_pilfer_constructible
, Valueless
Variants Considered Harmful
Convenience header <boost/json.hpp>