modm API documentation
modm::Pair< T1, T2 > Class Template Reference

Pair<FirstType, SecondType> is a heterogeneous pair. More...

#include <modm/container/pair.hpp>

Public Typedefs

typedef T1 FirstType
typedef T2 SecondType

Public Member Functions

FirstType & getFirst ()
const FirstType & getFirst () const
SecondType & getSecond ()
const SecondType & getSecond () const

Public Attributes

FirstType first
SecondType second

Detailed Description

template<typename T1, typename T2>
class modm::Pair< T1, T2 >

Pair<FirstType, SecondType> is a heterogeneous pair.

This class holds one object of type FirstType and one object of type SecondType.

It provides only the default constructors and public variables to enable usage as POD (plain old data) object. Only with this characteristic it is possible to storage objects of this type inside the flash-memory which is desirable for example for the interpolation classes.

See also

This constraint make a the usage rather unusual. See this example:

// construction
modm::Pair<uint8_t, uint16_t> pair = { 12, -12345 };
// this typedef is necessary to be able to use
// the type inside the FLASH macro
// put some values into the flash memory
FLASH_STORAGE(MyPair pairs[3]) =
{ 0, 10 },
{ 2, 30 },
{ 5, 60 }

As this class has no constructor you need to use the following syntax to initialize an instance of this class:

modm::Pair<int, float> pair = { 1203, 1035.234 };
Even if this class provides public attributes it is recommend to use the access methods, because as soon as C++0x is available the implementation will be changed and the attributes will be made private. Until then just ignore that you can access them directly ;-)
Fabian Greif

The documentation for this class was generated from the following file: