PMDK C++ bindings 1.13.0
This is the C++ bindings documentation for PMDK's libpmemobj.
Loading...
Searching...
No Matches
pair.hpp
1// SPDX-License-Identifier: BSD-3-Clause
2/* Copyright 2020, Intel Corporation */
3
4#ifndef LIBPMEMOBJ_PAIR_HPP
5#define LIBPMEMOBJ_PAIR_HPP
6
7#include <utility>
8
10
11namespace pmem
12{
13
14namespace detail
15{
16
17template <typename F, typename S>
18struct pair {
19 constexpr pair() : first(), second()
20 {
21 }
22
23 template <typename... Args1, typename... Args2>
24 pair(std::piecewise_construct_t pc, std::tuple<Args1...> first_args,
25 std::tuple<Args2...> second_args)
26 : pair(pc, first_args, second_args,
27 typename make_index_sequence<Args1...>::type{},
28 typename make_index_sequence<Args2...>::type{})
29 {
30 }
31
32 constexpr pair(const F &k, const S &v) : first(k), second(v)
33 {
34 }
35
36 template <typename K, typename V>
37 constexpr pair(K &&k, V &&v)
38 : first(std::forward<K>(k)), second(std::forward<V>(v))
39 {
40 }
41
42 template <typename K, typename V>
43 constexpr pair(const std::pair<K, V> &p)
44 : first(p.first), second(p.second)
45 {
46 }
47
48 template <typename K, typename V>
49 constexpr pair(std::pair<K, V> &&p)
50 : first(std::forward<K>(p.first)), second(std::forward<V>(p.second))
51 {
52 }
53
54 F first;
55 S second;
56
57private:
58 template <typename... Args1, typename... Args2, size_t... I1,
59 size_t... I2>
60 pair(std::piecewise_construct_t, std::tuple<Args1...> &first_args,
61 std::tuple<Args2...> &second_args, index_sequence<I1...>,
62 index_sequence<I2...>)
63 : first(std::forward<Args1>(std::get<I1>(first_args))...),
64 second(std::forward<Args2>(std::get<I2>(second_args))...)
65 {
66 }
67};
68
69template <class T1, class T2>
70bool
71operator==(const pair<T1, T2> &lhs, const pair<T1, T2> &rhs)
72{
73 return lhs.first == rhs.first && lhs.second == rhs.second;
74}
75
76template <class T1, class T2>
77bool
78operator!=(const pair<T1, T2> &lhs, const pair<T1, T2> &rhs)
79{
80 return !(lhs == rhs);
81}
82
83} /* namespace detail */
84
85} /* namespace pmem */
86
87#endif /* LIBPMEMOBJ_PAIR_HPP */
Create c++14 style index sequence.
T & get(pmem::obj::array< T, N > &a)
Non-member get function.
Definition: array.hpp:919
bool operator!=(const allocator< T, P, Tr > &lhs, const OtherAllocator &rhs)
Determines if memory from another allocator can be deallocated from this one.
Definition: allocator.hpp:536
bool operator==(standard_alloc_policy< T > const &, standard_alloc_policy< T2 > const &)
Determines if memory from another allocator can be deallocated from this one.
Definition: allocator.hpp:420
Persistent memory namespace.
Definition: allocation_flag.hpp:15