Loading...
Searching...
No Matches
mapping.hpp
/*
SPDX-License-Identifier: MIT
Copyright © 2023 Amebis
*/
#pragma once
#include "compat.hpp"
#include <vector>
namespace stdex
{
template <class T>
struct mapping {
T from; // index in source string
T to; // index in destination string
inline mapping() : from(0), to(0) {}
inline mapping(_In_ T x) : from(x), to(x) {}
inline mapping(_In_ T _from, _In_ T _to) : from(_from), to(_to) {}
inline bool operator==(const mapping& other) const { return from == other.from && to == other.to; }
inline bool operator!=(const mapping& other) const { return !operator==(other); }
};
template <class T, class _Alloc = std::allocator<mapping<T>>>
using mapping_vector = std::vector<mapping<T>, _Alloc>;
}
stdex::mapping
Maps index in source string to index in destination string.
Definition mapping.hpp:17
stdex::mapping::mapping
mapping(T x)
Constructs an id mapping.
Definition mapping.hpp:31
stdex::mapping::operator==
bool operator==(const mapping &other) const
Are mappings identical?
Definition mapping.hpp:48
stdex::mapping::mapping
mapping()
Constructs a zero to zero mapping.
Definition mapping.hpp:24
stdex::mapping::operator!=
bool operator!=(const mapping &other) const
Are mappings different?
Definition mapping.hpp:57
stdex::mapping::mapping
mapping(T _from, T _to)
Constructs a mapping.
Definition mapping.hpp:39