Skip to content

Commit 21f76e7

Browse files
committed
[container] Implement Pair using std::pair
1 parent fd8d79e commit 21f76e7

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

src/modm/container/pair.hpp

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright (c) 2009-2010, Martin Rosekeit
44
* Copyright (c) 2009-2011, Fabian Greif
55
* Copyright (c) 2012, Niklas Hauser
6+
* Copyright (c) 2023, Christopher Durand
67
*
78
* This file is part of the modm project.
89
*
@@ -15,6 +16,8 @@
1516
#ifndef MODM_PAIR_HPP
1617
#define MODM_PAIR_HPP
1718

19+
#include <utility>
20+
1821
namespace modm
1922
{
2023
/**
@@ -63,49 +66,38 @@ namespace modm
6366
* \ingroup modm_container
6467
*/
6568
template<typename T1, typename T2>
66-
class Pair
69+
class Pair : public std::pair<T1, T2>
6770
{
6871
public:
69-
typedef T1 FirstType;
70-
typedef T2 SecondType;
72+
using FirstType = T1;
73+
using SecondType = T2;
7174

7275
public:
73-
// No non-trivial constructor is allowed, otherwise this class
74-
// won't be POD (plain old data) :-(
75-
// (this behavior changes with C++0x)
76-
/*Pair(const FirstType& first, const SecondType& second) :
77-
first(first), second(second)
78-
{
79-
}*/
76+
using std::pair<T1, T2>::pair;
8077

8178
FirstType&
8279
getFirst()
8380
{
84-
return first;
81+
return this->first;
8582
}
8683

8784
const FirstType&
8885
getFirst() const
8986
{
90-
return first;
87+
return this->first;
9188
}
9289

9390
SecondType&
9491
getSecond()
9592
{
96-
return second;
93+
return this->second;
9794
}
9895

9996
const SecondType&
10097
getSecond() const
10198
{
102-
return second;
99+
return this->second;
103100
}
104-
105-
// ... not allowed either, only public attributes :-(
106-
//private:
107-
FirstType first;
108-
SecondType second;
109101
};
110102
}
111103

0 commit comments

Comments
 (0)