Loading...
Searching...
No Matches
pair
Go to the documentation of this file.
// vi:set ft=cpp: -*- Mode: C++ -*-
/*
* (c) 2008-2009 Alexander Warg <warg@os.inf.tu-dresden.de>
* economic rights: Technische Universität Dresden (Germany)
*
* License: see LICENSE.spdx (in this directory or the directories above)
*/
#pragma once
#include <l4/cxx/type_traits>
namespace cxx {
template< typename First, typename Second >
struct Pair
{
typedef First First_type;
typedef Second Second_type;
First first;
Second second;
template<typename A1, typename A2>
Pair(A1 &&first, A2 &&second)
: first(cxx::forward<A1>(first)), second(cxx::forward<A2>(second)) {}
template<typename A1>
Pair(A1 &&first)
: first(cxx::forward<A1>(first)), second() {}
Pair() = default;
};
template< typename F, typename S >
Pair<F,S> pair(F const &f, S const &s)
{ return cxx::Pair<F,S>(f,s); }
template< typename Cmp, typename Typ >
class Pair_first_compare
{
private:
Cmp const &_cmp;
public:
Pair_first_compare(Cmp const &cmp = Cmp()) : _cmp(cmp) {}
bool operator () (Typ const &l, Typ const &r) const
{ return _cmp(l.first,r.first); }
};
}
template< typename OS, typename A, typename B >
inline
OS &operator << (OS &os, cxx::Pair<A,B> const &p)
{
os << p.first << ';' << p.second;
return os;
}
cxx::Pair_first_compare::operator()
bool operator()(Typ const &l, Typ const &r) const
Do the comparison based on the first value.
Definition pair:91
cxx::Pair_first_compare::Pair_first_compare
Pair_first_compare(Cmp const &cmp=Cmp())
Construction.
Definition pair:84
cxx
Our C++ library.
Definition arith:11
cxx::Pair
Pair of two values.
Definition pair:28
cxx::Pair< KEY_TYPE, DATA_TYPE >::Second_type
DATA_TYPE Second_type
Definition pair:32
cxx::Pair::Pair
Pair(A1 &&first)
Create a pair, default constructing the second value.
Definition pair:53
cxx::Pair< KEY_TYPE, DATA_TYPE >::second
DATA_TYPE second
Definition pair:37
cxx::Pair< KEY_TYPE, DATA_TYPE >::First_type
KEY_TYPE First_type
Definition pair:30
cxx::Pair::Pair
Pair()=default
Default construction.
cxx::Pair::Pair
Pair(A1 &&first, A2 &&second)
Create a pair from the two values.
Definition pair:45
cxx::Pair< KEY_TYPE, DATA_TYPE >::first
KEY_TYPE first
Definition pair:35