|
Tiny Vector Matrix library using Expression Templates | Sourceforge Project Page |
Initialize classes using a comma separated lists. More...
#include <tvmet/CommaInitializer.h>
Classes | |
class | Initializer |
Helper fo recursive overloaded comma operator. More... | |
Public Types | |
typedef Obj::value_type | value_type |
typedef value_type * | iterator |
Public Member Functions | |
CommaInitializer (const CommaInitializer &rhs) | |
CommaInitializer (Obj &obj, value_type x) | |
Constructor used by Vector or Matrix operator(value_type rhs) | |
~CommaInitializer () | |
Destructs and assigns the comma separated value. | |
Initializer< value_type, 2 > | operator, (value_type rhs) |
Overloaded comma operator, called only once for the first occoured comma. | |
void | disable () const |
Private Member Functions | |
CommaInitializer () | |
CommaInitializer & | operator= (const CommaInitializer &) |
Private Attributes | |
Obj & | m_object |
value_type | m_data |
bool | m_wipeout_on_destruct |
Initialize classes using a comma separated lists.
The comma operator is called when it appears next to an object of the type the comma is defined for. However, "operator," is not called for function argument lists, only for objects that are out in the open, separated by commas (Thinking C++ Ch.12: Operator comma).
This implementation uses the same technique as described in Todd Veldhuizen Techniques for Scientific C++ chapter 1.11 Comma overloading.
The initializer list is avaible after instanciation of the object, therefore use it like:
vector3d t; t = 1.0, 2.0, 3.0;
It's evaluated to (((t = 1.0), 2.0), 3.0)
For matrizes the initilization is done row wise.
If the comma separted list of values longer then the size of the vector or matrix a compile time error will occour. Otherwise the pending values will be written random into the memory.
typedef value_type* tvmet::CommaInitializer< Obj, LEN >::iterator |
typedef Obj::value_type tvmet::CommaInitializer< Obj, LEN >::value_type |
tvmet::CommaInitializer< Obj, LEN >::CommaInitializer | ( | ) | [private] |
tvmet::CommaInitializer< Obj, LEN >::CommaInitializer | ( | const CommaInitializer< Obj, LEN > & | rhs | ) | [inline] |
References tvmet::CommaInitializer< Obj, LEN >::disable().
tvmet::CommaInitializer< Obj, LEN >::CommaInitializer | ( | Obj & | obj, |
value_type | x | ||
) | [inline] |
tvmet::CommaInitializer< Obj, LEN >::~CommaInitializer | ( | ) | [inline] |
Destructs and assigns the comma separated value.
References tvmet::CommaInitializer< Obj, LEN >::m_data, tvmet::CommaInitializer< Obj, LEN >::m_object, and tvmet::CommaInitializer< Obj, LEN >::m_wipeout_on_destruct.
void tvmet::CommaInitializer< Obj, LEN >::disable | ( | ) | const [inline] |
CommaInitializer< Obj, LEN >::template Initializer< typename Obj::value_type, 2 > tvmet::CommaInitializer< Obj, LEN >::operator, | ( | typename Obj::value_type | rhs | ) |
Overloaded comma operator, called only once for the first occoured comma.
This means the first value is assigned by operator=() and the 2nd value after the comma. Therfore we call the Initializer::operator,() for the list starting after the 2nd.
CommaInitializer& tvmet::CommaInitializer< Obj, LEN >::operator= | ( | const CommaInitializer< Obj, LEN > & | ) | [private] |
value_type tvmet::CommaInitializer< Obj, LEN >::m_data [private] |
Referenced by tvmet::CommaInitializer< Obj, LEN >::~CommaInitializer().
Obj& tvmet::CommaInitializer< Obj, LEN >::m_object [private] |
Referenced by tvmet::CommaInitializer< Obj, LEN >::~CommaInitializer().
bool tvmet::CommaInitializer< Obj, LEN >::m_wipeout_on_destruct [mutable, private] |
Author: |