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

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

#include <modm/container/pair.hpp>

Inheritance diagram for modm::Pair< T1, T2 >:

Public Typedefs

using FirstType = T1
 
using SecondType = T2
 

Public Member Functions

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

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
modm::interpolation::Linear

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 };
Note
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 ;-)
Author
Fabian Greif

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