L4Re Operating System Framework – Interface and Usage Documentation
Loading...
Searching...
No Matches
pair
Go to the documentation of this file.
1// vi:set ft=cpp: -*- Mode: C++ -*-
6/*
7 * (c) 2008-2009 Alexander Warg <warg@os.inf.tu-dresden.de>
8 * economic rights: Technische Universität Dresden (Germany)
9 *
10 * This file is part of TUD:OS and distributed under the terms of the
11 * GNU General Public License 2.
12 * Please see the COPYING-GPL-2 file for details.
13 *
14 * As a special exception, you may use this file as part of a free software
15 * library without restriction. Specifically, if other files instantiate
16 * templates or use macros or inline functions from this file, or you compile
17 * this file and link it with other files to produce an executable, this
18 * file does not by itself cause the resulting executable to be covered by
19 * the GNU General Public License. This exception does not however
20 * invalidate any other reasons why the executable file might be covered by
21 * the GNU General Public License.
22 */
23#pragma once
24
25namespace cxx {
26
35template< typename First, typename Second >
36struct Pair
37{
39 typedef First First_type;
41 typedef Second Second_type;
42
44 First first;
46 Second second;
47
53 template<typename A1, typename A2>
54 Pair(A1 &&first, A2 &&second)
55 : first(first), second(second) {}
56
58 Pair() = default;
59};
60
61template< typename F, typename S >
62Pair<F,S> pair(F const &f, S const &s)
63{ return cxx::Pair<F,S>(f,s); }
64
65
74template< typename Cmp, typename Typ >
76{
77private:
78 Cmp const &_cmp;
79
80public:
85 Pair_first_compare(Cmp const &cmp = Cmp()) : _cmp(cmp) {}
86
92 bool operator () (Typ const &l, Typ const &r) const
93 { return _cmp(l.first,r.first); }
94};
95
96}
97
98template< typename OS, typename A, typename B >
99inline
100OS &operator << (OS &os, cxx::Pair<A,B> const &p)
101{
102 os << p.first << ';' << p.second;
103 return os;
104}
105
Comparison functor for Pair.
Definition pair:76
bool operator()(Typ const &l, Typ const &r) const
Do the comaprison based on the first value.
Definition pair:92
Pair_first_compare(Cmp const &cmp=Cmp())
Construction.
Definition pair:85
Our C++ library.
Definition arith:22
Pair of two values.
Definition pair:37
Second Second_type
Type of second value.
Definition pair:41
Second second
Second value.
Definition pair:46
First First_type
Type of first value.
Definition pair:39
Pair()=default
Default construction.
Pair(A1 &&first, A2 &&second)
Create a pair from the two values.
Definition pair:54
First first
First value.
Definition pair:44