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

Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
tvmet::CommaInitializer< Obj, LEN > Class Template Reference

Initialize classes using a comma separated lists. More...

#include <tvmet/CommaInitializer.h>

List of all members.

Classes

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

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

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.


Member Typedef Documentation

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

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]

Member Function Documentation

template<class Obj , std::size_t LEN>
void tvmet::CommaInitializer< Obj, LEN >::disable ( ) const [inline]
template<class Obj , std::size_t LEN>
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.

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

Member Data Documentation

template<class Obj , std::size_t LEN>
value_type tvmet::CommaInitializer< Obj, LEN >::m_data [private]
template<class Obj , std::size_t LEN>
Obj& tvmet::CommaInitializer< Obj, LEN >::m_object [private]
template<class Obj , std::size_t LEN>
bool tvmet::CommaInitializer< Obj, LEN >::m_wipeout_on_destruct [mutable, private]
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Defines

Author: