mn_compressed_pair.hpp
Go to the documentation of this file.
1 /*
2 *This file is part of the Mini Thread Library (https://github.com/RoseLeBlood/MiniThread ).
3 *Copyright (c) 2018 Amber-Sophia Schroeck
4 *
5 *The Mini Thread Library is free software; you can redistribute it and/or modify
6 *it under the terms of the GNU Lesser General Public License as published by
7 *the Free Software Foundation, version 3, or (at your option) any later version.
8 
9 *The Mini Thread Library is distributed in the hope that it will be useful, but
10 *WITHOUT ANY WARRANTY; without even the implied warranty of
11 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 *General Public License for more details.
13 *
14 *You should have received a copy of the GNU Lesser General Public
15 *License along with the Mini Thread Library; if not, see
16 *<https://www.gnu.org/licenses/>.
17 */
18 #ifndef __MINILIB_EBCO_COMPRESSED_PAIR_H__
19 #define __MINILIB_EBCO_COMPRESSED_PAIR_H__
20 
21 #include "../mn_config.hpp"
22 
23 #include "../mn_algorithm.hpp"
24 #include "mn_ebo_storage.hpp"
25 
26 namespace mn {
27 
34  template <typename T, typename U, typename = void>
36  public:
38 
45 
46  constexpr compressed_pair() = default;
48  : m_first(f) { }
49 
51  : m_second(s) { }
52 
54  : m_first(f), m_second(s) { }
55 
56  constexpr compressed_pair(const self_type& other) noexcept
57  : compressed_pair(other.first(), other.second() ) { }
58 
59 
60  first_reference first() noexcept { return m_first.get(); }
61  constexpr first_const_reference first() const noexcept { return m_first.get(); }
62 
63  second_reference second() noexcept { return m_second.get(); }
64  constexpr second_const_reference second() const noexcept { return m_second.get(); }
65 
66  void swap(self_type& o) {
69  }
70  private:
73  };
74 }
75 
76 #endif // __MINILIB_EBCO_COMPRESSED_PAIR_H__
Definition: mn_compressed_pair.hpp:35
constexpr second_const_reference second() const noexcept
Definition: mn_compressed_pair.hpp:64
constexpr compressed_pair(first_const_reference f, second_const_reference s) noexcept
Definition: mn_compressed_pair.hpp:53
ebo_storage< T, 0 > m_first
Definition: mn_compressed_pair.hpp:71
typename type_traits< T >::reference first_reference
Definition: mn_compressed_pair.hpp:40
constexpr compressed_pair()=default
typename type_traits< T >::const_reference first_const_reference
Definition: mn_compressed_pair.hpp:41
typename type_traits< U >::reference second_reference
Definition: mn_compressed_pair.hpp:43
constexpr compressed_pair(const self_type &other) noexcept
Definition: mn_compressed_pair.hpp:56
typename type_traits< T >::value_type first_value_type
Definition: mn_compressed_pair.hpp:39
compressed_pair(first_const_reference f) noexcept
Definition: mn_compressed_pair.hpp:47
typename type_traits< U >::const_reference second_const_reference
Definition: mn_compressed_pair.hpp:44
second_reference second() noexcept
Definition: mn_compressed_pair.hpp:63
constexpr first_const_reference first() const noexcept
Definition: mn_compressed_pair.hpp:61
first_reference first() noexcept
Definition: mn_compressed_pair.hpp:60
ebo_storage< U, 1 > m_second
Definition: mn_compressed_pair.hpp:72
compressed_pair(second_const_reference s) noexcept
Definition: mn_compressed_pair.hpp:50
typename type_traits< U >::value_type second_value_type
Definition: mn_compressed_pair.hpp:42
void swap(self_type &o)
Definition: mn_compressed_pair.hpp:66
reference get() noexcept
Definition: mn_ebo_storage.hpp:40
Definition: mn_allocator_typetraits.hpp:25
const T & const_reference
Definition: mn_typetraits.hpp:34
void swap(TAssignable &a, TAssignable &b)
Definition: mn_algorithm.hpp:312
T value_type
Definition: mn_typetraits.hpp:31
T & reference
Definition: mn_typetraits.hpp:33