ICRS Eurobot 2013

Dependencies:   mbed mbed-rtos Servo QEI

Embed: (wiki syntax)

« Back to documentation index

CommaInitializer< Obj, LEN > Class Template Reference

CommaInitializer< Obj, LEN > Class Template Reference

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

#include <tvmet/CommaInitializer.h>

Public Member Functions

 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.

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.

Definition at line 64 of file CommaInitializer.h.


Constructor & Destructor Documentation

CommaInitializer ( Obj &  obj,
value_type  x 
)

Constructor used by Vector or Matrix operator(value_type rhs)

Definition at line 113 of file CommaInitializer.h.

Destructs and assigns the comma separated value.

Definition at line 120 of file CommaInitializer.h.


Member Function Documentation

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