mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-12-18 10:36:59 +00:00
Add all the files
This commit is contained in:
parent
e3db07a16a
commit
d60742f52b
1445 changed files with 430238 additions and 0 deletions
35
src/util/helpers/MapAdaptor.h
Normal file
35
src/util/helpers/MapAdaptor.h
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#pragma once
|
||||
|
||||
// https://ideone.com/k0H8Ei
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
|
||||
template <typename T, typename F>
|
||||
struct map_adaptor
|
||||
{
|
||||
map_adaptor(const T& t, const F& f) : _t(t), _f(f) {}
|
||||
map_adaptor(map_adaptor& a) = delete;
|
||||
map_adaptor(map_adaptor&& a) = default;
|
||||
|
||||
[[nodiscard]] auto begin() { return boost::make_transform_iterator(_t.begin(), _f); }
|
||||
[[nodiscard]] auto end() { return boost::make_transform_iterator(_t.end(), _f); }
|
||||
|
||||
[[nodiscard]] auto cbegin() const { return boost::make_transform_iterator(_t.cbegin(), _f); }
|
||||
[[nodiscard]] auto cend() const { return boost::make_transform_iterator(_t.cend(), _f); }
|
||||
|
||||
protected:
|
||||
const T& _t;
|
||||
F _f;
|
||||
};
|
||||
|
||||
|
||||
template <typename T, typename F>
|
||||
auto get_map_adaptor(const T& t, const F& f) { return map_adaptor<T, F>(t, f); }
|
||||
|
||||
template <typename T>
|
||||
auto get_keys(const T& t) { return get_map_adaptor(t, [](const auto& p) { return p.first; }); }
|
||||
|
||||
template <typename T>
|
||||
auto get_values(const T& t) { return get_map_adaptor(t, [](const auto& p) { return p.second; }); }
|
||||
Loading…
Add table
Add a link
Reference in a new issue