cpp/memory/inout ptr t

is used to adapt types such as smart pointers for foreign functions that reset ownership via a (usually  for some object type ) or  parameter.

captures additional arguments on construction, provides a storage for the result which such an aforementioned foreign function accesses, releases the ownership held by the adapted object, and finally resets the adapted  object with the result and the captured arguments when it is destroyed.

behaves as if it holds following non-static data members:
 * a reference, which is bound to the adapted object on construction,
 * for every in, a member of type , which is an argument captured on construction and used for resetting while destruction, and
 * a member subobject that suitable for storing a within it and providing a  object, where the  or  object is generally exposed to a foreign function for ownership resetting.

If is not a pointer type,  is called at most once on the adapted object. Implementations may call within constructor, or before resetting within destructor if the  value is not null.

Users can control whether each argument for resetting is captured by copy or by reference, by specifying an object type or a reference type in respectively.

Specializations
Unlike most class templates in the standard library, program-defined specializations of that depend on at least one program-defined type need not meet the requirements for the primary template.

This license allows a program-defined specialization to expose the raw pointer stored within a non-standard smart pointer to foreign functions.