SourceForge Logo Tiny Vector Matrix library using Expression Templates Sourceforge Project Page

tvmet::CommaInitializer< Obj, LEN > Class Template Reference

#include <tvmet/CommaInitializer.h>

Collaboration diagram for tvmet::CommaInitializer< Obj, LEN >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class Obj, std::size_t LEN>
class tvmet::CommaInitializer< Obj, LEN >

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.


Public Types

typedef Obj::value_type value_type
typedef value_typeiterator

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 ()
CommaInitializeroperator= (const CommaInitializer &)

Private Attributes

Obj & m_object
value_type m_data
bool m_wipeout_on_destruct

Classes

class  Initializer
 Helper fo recursive overloaded comma operator. More...


Member Typedef Documentation

template<class Obj, std::size_t LEN>
typedef Obj::value_type tvmet::CommaInitializer< Obj, LEN >::value_type

template<class Obj, std::size_t LEN>
typedef value_type* tvmet::CommaInitializer< Obj, LEN >::iterator


Constructor & Destructor Documentation

template<class Obj, std::size_t LEN>
tvmet::CommaInitializer< Obj, LEN >::CommaInitializer (  )  [private]

template<class Obj, std::size_t LEN>
tvmet::CommaInitializer< Obj, LEN >::CommaInitializer ( const CommaInitializer< Obj, LEN > &  rhs  )  [inline]

template<class Obj, std::size_t LEN>
tvmet::CommaInitializer< Obj, LEN >::CommaInitializer ( Obj &  obj,
value_type  x 
) [inline]

Constructor used by Vector or Matrix operator(value_type rhs).

template<class Obj, std::size_t LEN>
tvmet::CommaInitializer< Obj, LEN >::~CommaInitializer (  )  [inline]

Destructs and assigns the comma separated value.


Member Function Documentation

template<class Obj, std::size_t LEN>
CommaInitializer& tvmet::CommaInitializer< Obj, LEN >::operator= ( const CommaInitializer< Obj, LEN > &   )  [private]

template<class Obj, std::size_t LEN>
CommaInitializer< Obj, LEN >::template Initializer< typename Obj::value_type, 2 > tvmet::CommaInitializer< Obj, LEN >::operator, ( value_type  rhs  )  [inline]

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 Initializeroperator,() for the list starting after the 2nd.

template<class Obj, std::size_t LEN>
void tvmet::CommaInitializer< Obj, LEN >::disable (  )  const [inline]


Member Data Documentation

template<class Obj, std::size_t LEN>
Obj& tvmet::CommaInitializer< Obj, LEN >::m_object [private]

template<class Obj, std::size_t LEN>
value_type tvmet::CommaInitializer< Obj, LEN >::m_data [private]

template<class Obj, std::size_t LEN>
bool tvmet::CommaInitializer< Obj, LEN >::m_wipeout_on_destruct [mutable, private]


Author: