mdds
Loading...
Searching...
No Matches
ref_pair.hpp
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3// SPDX-FileCopyrightText: 2020 - 2025 Kohei Yoshida
4//
5// SPDX-License-Identifier: MIT
6
7#pragma once
8
9#include <type_traits>
10#include <utility>
11
12namespace mdds {
13
22template<typename T1, typename T2>
23struct ref_pair
24{
25 using first_type = std::add_lvalue_reference_t<T1>;
26 using second_type = std::add_lvalue_reference_t<T2>;
27
28 first_type first;
29 second_type second;
30
31 ref_pair(first_type _first, second_type _second) : first(_first), second(_second)
32 {}
33
34 ref_pair(const ref_pair& other) = default;
35
36 bool operator==(const std::pair<std::decay_t<T1>, std::decay_t<T2>>& other) const
37 {
38 return first == other.first && second == other.second;
39 }
40
41 bool operator==(const ref_pair& other) const
42 {
43 return first == other.first && second == other.second;
44 }
45
46 ref_pair* operator->()
47 {
48 return this;
49 }
50};
51
52} // namespace mdds
53
54/* vim:set shiftwidth=4 softtabstop=4 expandtab: */