stdex
Additional custom or not Standard C++ covered algorithms
Loading...
Searching...
No Matches
mapping.hpp
1/*
2 SPDX-License-Identifier: MIT
3 Copyright © 2023 Amebis
4*/
5
6#pragma once
7
8#include "sal.hpp"
9#include <vector>
10
11namespace stdex
12{
16 template <class T>
17 struct mapping {
18 T from; // index in source string
19 T to; // index in destination string
20
21 inline mapping() : from(0), to(0) {}
22 inline mapping(_In_ T x) : from(x), to(x) {}
23 inline mapping(_In_ T _from, _In_ T _to) : from(_from), to(_to) {}
24
25 friend bool operator ==(_In_ stdex::mapping<T> const& a, _In_ stdex::mapping<T> const& b) noexcept { return a.from == b.from && a.to == b.to; }
26 friend bool operator !=(_In_ stdex::mapping<T> const& a, _In_ stdex::mapping<T> const& b) noexcept { return !(a == b); }
27 };
28
29 template <class T, class _Alloc = std::allocator<mapping<T>>>
30 using mapping_vector = std::vector<mapping<T>, _Alloc>;
31}
Maps index in source string to index in destination string.
Definition: mapping.hpp:17