Drake
NameValue< T > Class Template Reference

Detailed Description

template<typename T>
class drake::NameValue< T >

A basic implementation of the Name-Value Pair concept as used in the Serialize / Archive pattern.

See, for example: https://www.boost.org/doc/libs/release/libs/serialization/doc/wrappers.html#nvp

NameValue stores a pointer to a const name and a pointer to a mutable value. Both pointers must remain valid throughout the lifetime of an object. NameValue objects are typically short-lived, existing only for a transient moment while an Archive is visiting some Serializable field.

#include <drake/common/name_value.h>

Public Types

typedef T value_type
 Type of the referenced value. More...
 

Public Member Functions

 NameValue (const char *name_in, T *value_in)
 (Advanced.) Constructs a NameValue. More...
 
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable
 NameValue (const NameValue &)=default
 
NameValueoperator= (const NameValue &)=default
 
 NameValue (NameValue &&)=default
 
NameValueoperator= (NameValue &&)=default
 
Accessors to the raw pointers
const char * name () const
 
T * value () const
 

Member Typedef Documentation

◆ value_type

typedef T value_type

Type of the referenced value.

Constructor & Destructor Documentation

◆ NameValue() [1/3]

NameValue ( const NameValue< T > &  )
default

◆ NameValue() [2/3]

NameValue ( NameValue< T > &&  )
default

◆ NameValue() [3/3]

NameValue ( const char *  name_in,
T *  value_in 
)

(Advanced.) Constructs a NameValue.

Prefer DRAKE_NVP instead of this constructor. Both pointers are aliased and must remain valid for the lifetime of this object. Neither pointer can be nullptr.

Member Function Documentation

◆ name()

const char* name ( ) const

◆ operator=() [1/2]

NameValue& operator= ( NameValue< T > &&  )
default

◆ operator=() [2/2]

NameValue& operator= ( const NameValue< T > &  )
default

◆ value()

T* value ( ) const

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