ADOL-C: Automatic Differentiation in C/C++ 2.7.3
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
tape_location< T > Class Template Reference

RAII type for a location in the current tape's value store. More...

#include <adtb_types.h>

Public Types

enum  ownership_mode { INVALID = 0 , OWNING = 1 , BORROWED = 2 }
 

Public Member Functions

 ~tape_location ()
 Release an owned active-value location; leave borrowed locations alone.
 
 tape_location ()
 Constructs a tape_location with the next available location on the tape.
 
 tape_location (size_t loc, ownership_mode mode=OWNING)
 Constructs a tape location from an existing location.
 
 tape_location (const tape_location &)=delete
 Deleted copy constructor.
 
tape_location & operator= (const tape_location &)=delete
 Deleted copy assignment operator.
 
 tape_location (tape_location &&other) noexcept
 Transfer the location and its ownership state; invalidate the source.
 
tape_location & operator= (tape_location &&other) noexcept
 Release the old owned location and transfer the source state.
 
size_t loc () const
 Retrieves the tape location.
 
bool owns_location () const
 Returns whether this location owns tape memory.
 
bool is_valid () const
 
size_t release ()
 Return the location index and invalidate this token.
 

Detailed Description

template<adouble_or_pdouble T>
class tape_location< T >

RAII type for a location in the current tape's value store.

adouble and pdouble use this helper to allocate, transfer, borrow, and release locations. It stores only the location index, so construction, destruction, and use must occur while the corresponding ValueTape is current. User code should not call next_loc() or free_loc() directly.

Template Parameters
TEither adouble or pdouble.

Member Enumeration Documentation

◆ ownership_mode

State model:

  • OWNING: usable token, frees tape location in destructor.
  • BORROWED: usable token, does not free tape location.
  • INVALID: unusable token (e.g., moved-from / release_loc source).

This separation is required to prevent "use-after-release" while still allowing borrowed bridge objects from the C interface to participate in operations.

Enumerator
INVALID 
OWNING 
BORROWED 

Constructor & Destructor Documentation

◆ ~tape_location()

template<adouble_or_pdouble T>
tape_location< T >::~tape_location ( )
inline

Release an owned active-value location; leave borrowed locations alone.

◆ tape_location() [1/4]

template<adouble_or_pdouble T>
tape_location< T >::tape_location ( )
inline

Constructs a tape_location with the next available location on the tape.

◆ tape_location() [2/4]

template<adouble_or_pdouble T>
tape_location< T >::tape_location ( size_t  loc,
ownership_mode  mode = OWNING 
)
inlineexplicit

Constructs a tape location from an existing location.

Parameters
locExisting tape location.
modeOwnership mode (owning or borrowed).

◆ tape_location() [3/4]

template<adouble_or_pdouble T>
tape_location< T >::tape_location ( const tape_location< T > &  )
delete

Deleted copy constructor.

◆ tape_location() [4/4]

template<adouble_or_pdouble T>
tape_location< T >::tape_location ( tape_location< T > &&  other)
inlinenoexcept

Transfer the location and its ownership state; invalidate the source.

Parameters
otherThe tape_location to move from.

Member Function Documentation

◆ is_valid()

template<adouble_or_pdouble T>
bool tape_location< T >::is_valid ( ) const
inline

◆ loc()

template<adouble_or_pdouble T>
size_t tape_location< T >::loc ( ) const
inline

Retrieves the tape location.

Returns
The index of the location on the tape.

◆ operator=() [1/2]

template<adouble_or_pdouble T>
tape_location & tape_location< T >::operator= ( const tape_location< T > &  )
delete

Deleted copy assignment operator.

◆ operator=() [2/2]

template<adouble_or_pdouble T>
tape_location & tape_location< T >::operator= ( tape_location< T > &&  other)
inlinenoexcept

Release the old owned location and transfer the source state.

Parameters
otherThe tape_location to move from.
Returns
Reference to the updated tape_location.

◆ owns_location()

template<adouble_or_pdouble T>
bool tape_location< T >::owns_location ( ) const
inline

Returns whether this location owns tape memory.

◆ release()

template<adouble_or_pdouble T>
size_t tape_location< T >::release ( )
inline

Return the location index and invalidate this token.

The location remains allocated. The caller is responsible for its lifetime.


The documentation for this class was generated from the following file: