| 
|   | ReinitOnCopy ()=delete | 
|   | Default constructor is deleted; use ResetOnCopy instead.  More...
  | 
|   | 
|   | ReinitOnCopy (const T &value) | 
|   | Construct or implicitly convert from an object of type T. This sets both the current and remembered initial value to the given value.  More...
  | 
|   | 
|   | ReinitOnCopy (T &&value) | 
|   | Construct or implicitly convert from an rvalue object of type T. This sets both the current and remembered initial value to the given value.  More...
  | 
|   | 
|   | ReinitOnCopy (const ReinitOnCopy &source) | 
|   | Copy constructor sets the value and remembered initial value to the initial value in the source, using type T's copy constructor.  More...
  | 
|   | 
|   | ReinitOnCopy (ReinitOnCopy &&source) | 
|   | Move constructor is simply a pass-through to the move constructor of the contained object for both the current and initial values.  More...
  | 
|   | 
| ReinitOnCopy &  | operator= (const ReinitOnCopy &ignored) | 
|   | Copy assignment reinitializes this object to its original condition; the source argument is ignored.  More...
  | 
|   | 
| ReinitOnCopy &  | operator= (ReinitOnCopy &&source) | 
|   | Move assignment uses type T's move assignment for the current value but does not change the remembered initial value here.  More...
  | 
|   | 
| ReinitOnCopy &  | operator= (const T &value) | 
|   | Assignment from an object of type T uses T's copy assignment operator; affects only the current value but does not change the remembered initial value.  More...
  | 
|   | 
| ReinitOnCopy &  | operator= (T &&value) | 
|   | Assignment from an rvalue object of type T uses T's move or copy assignment operator; affects only the current value but does not change the remembered initial value.  More...
  | 
|   | 
| const T &  | getT () const | 
|   | Return a const reference to the contained object of type T.  More...
  | 
|   | 
| T &  | updT () | 
|   | Return a writable reference to the contained object of type T.  More...
  | 
|   | 
| const T &  | getReinitT () const | 
|   | (Advanced) Return a const reference to the stored initial value.  More...
  | 
|   | 
| T &  | updReinitT () | 
|   | (Advanced) Return a writable reference to the stored initial value. Use of this should be rare and restricted to constructors.  More...
  | 
|   | 
template<class T>
class SimTK::ReinitOnCopy< T >
Ensures that a data member of type T is automatically reinitialized to a given initial value upon copy construction or copy assignment. This allows the compiler-generated default copy methods to be used. 
The template type T here is required to be CopyAssignable, CopyConstructible, and Destructible, and cannot be an array type. There is space overhead here for one extra copy of T used to hold the initial value. The default constructor is suppressed here; if you just need the data member reset to zero or to its default-constructed value, use class ResetOnCopy<T> instead. That class has zero overhead and accepts a wider range of template arguments.
Here are some usage examples: 
class Thing {
    
    ReinitOnCopy<int>         m_which{-1};          
    ReinitOnCopy<string>      m_name{"unknown"};    
    ReinitOnCopy<const char*> m_desc{"none given"}; 
    ReinitOnCopy<Color>       m_color{
Blue};        
    
    ResetOnCopy<unsigned>     m_count1;     
    ReinitOnCopy<unsigned>    m_count2;     
    ReinitOnCopy<unsigned>    m_count3{0};  
    
    ResetOnCopy<std::unique_ptr<Something>> m_myThing;
};
Other than copy behavior, an object of type ReinitOnCopy<T> behaves just like the underlying object of type T. It will implicitly convert to T when needed, and inherit constructors, assignment, and other methods from T. Move construction and move assignment behave as they would for T, and an assignment from an object of type T to an object of type ReinitOnCopy<T> will invoke T's ordinary copy assignment operator if there is one, and fail to compile if an attempt is made to use a non-existent assignment operator.
- Template Parameters
 - 
  
    | T | Template type that is a numeric, character, enum, or pointer built-in type, or a class type that is CopyConstructible, CopyAssignable, and Destructible. Array types are not allowed. | 
  
   
- See also
 - ResetOnCopy if you only need to reinitialize to the default value.