Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Concepts
pair.hpp
Go to the documentation of this file.
1
6/*
7 * This file is part of Algorithms library toolkit.
8 * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
9
10 * Algorithms library toolkit is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14
15 * Algorithms library toolkit is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19
20 * You should have received a copy of the GNU General Public License
21 * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24#pragma once
25
26#include <ext/ostream>
27
30
31namespace ext {
32
42template < class T, class R >
43class pair : public std::pair < T, R > {
44public:
48 using std::pair < T, R >::pair; // NOLINT(modernize-use-equals-default)
49
53 using std::pair < T, R >::operator =;
54#ifndef __clang__
55
59 pair ( const pair & other ) = default;
60
64 pair ( pair && other ) = default;
65
69 pair & operator = ( pair && other ) = default;
70
74 pair & operator = ( const pair & other ) = default;
75#endif
76};
77
78template<typename T1, typename T2>
79constexpr auto make_pair ( T1 && x, T2 && y ) {
80 typedef typename ext::strip_reference_wrapper < std::decay_t < T1 > >::type ds_type1;
81 typedef typename ext::strip_reference_wrapper < std::decay_t < T2 > >::type ds_type2;
82 return pair < ds_type1, ds_type2 > ( std::forward < T1 > ( x ), std::forward < T2 > ( y ) );
83}
84
97template< class T, class R >
99 out << "(" << pair.first << ", " << pair.second << ")";
100 return out;
101}
102
103} /* namespace ext */
104
105namespace std {
106
114template < class First, class Second >
115struct tuple_size < ext::pair < First, Second > > : public std::integral_constant < std::size_t, 2 > { };
116
127template < std::size_t I, class First, class Second >
128struct tuple_element < I, ext::pair < First, Second > > {
129 typedef typename std::tuple_element < I, std::pair < First, Second > >::type type;
130};
131
132} /* namespace std */
Definition: ostream.h:14
Class extending the pair class from the standard library. Original reason is to allow printing of the...
Definition: pair.hpp:43
pair(pair &&other)=default
pair & operator=(pair &&other)=default
pair(const pair &other)=default
Definition: sigHandler.cpp:20
constexpr auto make_pair(T1 &&x, T2 &&y)
Definition: pair.hpp:79
std::ostream & operator<<(ext::reference_wrapper< std::ostream > &os, std::ostream &(*const func)(std::ostream &))
Overloaded function allowing same operations on wrapped output stream as on the actual output stream,...
Definition: GlobalData.cpp:33
Definition: FordFulkerson.hpp:16
Definition: type_traits.hpp:170
std::tuple_element< I, std::pair< First, Second > >::type type
Definition: pair.hpp:129