2022-10-09 05:13:17 +00:00
|
|
|
#ifndef _RSTL_PAIR
|
|
|
|
#define _RSTL_PAIR
|
2022-04-10 00:17:06 +00:00
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
|
|
|
|
namespace rstl {
|
|
|
|
template < typename L, typename R >
|
|
|
|
class pair {
|
|
|
|
public:
|
2022-11-02 01:21:07 +00:00
|
|
|
pair() {}
|
|
|
|
pair(const L& first, const R& second) : first(first), second(second) {}
|
2022-10-10 21:46:32 +00:00
|
|
|
|
2022-11-30 21:26:00 +00:00
|
|
|
bool operator==(const pair& other) const { return first == other.first && second == other.second; }
|
|
|
|
|
2022-04-11 22:42:08 +00:00
|
|
|
L first;
|
|
|
|
R second;
|
2022-04-10 00:17:06 +00:00
|
|
|
};
|
2022-12-05 21:35:31 +00:00
|
|
|
|
|
|
|
template < typename P >
|
|
|
|
struct select1st {
|
|
|
|
const P& operator()(const P& it) const { return it; }
|
|
|
|
};
|
|
|
|
|
|
|
|
template < typename K, typename V >
|
|
|
|
struct select1st< pair< K, V > > {
|
|
|
|
typedef K value_type;
|
|
|
|
|
|
|
|
const K& operator()(const pair< K, V >& it) const { return it.first; }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-04-10 00:17:06 +00:00
|
|
|
} // namespace rstl
|
|
|
|
|
2022-10-09 05:13:17 +00:00
|
|
|
#endif // _RSTL_PAIR
|