openMSX
|
#include <algorithm>
#include <cassert>
#include <functional>
#include <iterator>
#include <initializer_list>
#include <map>
#include <numeric>
#include <tuple>
#include <utility>
#include <variant>
#include <vector>
Go to the source code of this file.
Classes | |
struct | uninitialized_tag |
struct | always_true |
struct | overloaded< Ts > |
struct | get_index_tag< typename > |
struct | get_index< T, std::variant< Ts... > > |
struct | array_with_enum_index< Enum, T, S > |
class | iterator_range< Iterator, Sentinel > |
Namespaces | |
namespace | detail |
Typedefs | |
template<typename T , typename Iterator > | |
using | detail::ToVectorType = std::conditional_t< std::is_same_v< T, void >, typename std::iterator_traits< Iterator >::value_type, T > |
Functions | |
template<typename ITER , typename VAL > | |
constexpr bool | contains (ITER first, ITER last, const VAL &val) |
Check if a range contains a given value, using linear search. | |
template<typename RANGE , typename VAL > | |
constexpr bool | contains (const RANGE &range, const VAL &val) |
template<typename ITER , typename VAL , typename Proj > | |
bool | contains (ITER first, ITER last, const VAL &val, Proj proj) |
template<typename RANGE , typename VAL , typename Proj > | |
bool | contains (const RANGE &range, const VAL &val, Proj proj) |
template<typename ITER , typename VAL , typename Proj = std::identity> | |
ITER | find_unguarded (ITER first, ITER last, const VAL &val, Proj proj={}) |
Faster alternative to 'find' when it's guaranteed that the value will be found (if not the behavior is undefined). | |
template<typename RANGE , typename VAL , typename Proj = std::identity> | |
auto | find_unguarded (RANGE &range, const VAL &val, Proj proj={}) |
template<typename ITER , typename PRED > | |
constexpr ITER | find_if_unguarded (ITER first, ITER last, PRED pred) |
Faster alternative to 'find_if' when it's guaranteed that the predicate will be true for at least one element in the given range. | |
template<typename RANGE , typename PRED > | |
constexpr auto | find_if_unguarded (RANGE &range, PRED pred) |
template<typename RANGE , typename VAL , typename Proj = std::identity> | |
auto | rfind_unguarded (RANGE &range, const VAL &val, Proj proj={}) |
Similar to the find(_if)_unguarded functions above, but searches from the back to front. | |
template<typename RANGE , typename PRED > | |
constexpr auto | rfind_if_unguarded (RANGE &range, PRED pred) |
template<typename VECTOR > | |
void | move_pop_back (VECTOR &v, typename VECTOR::iterator it) |
Erase the pointed to element from the given vector. | |
template<typename ForwardIt , typename OutputIt , typename UnaryPredicate > | |
std::pair< OutputIt, ForwardIt > | partition_copy_remove (ForwardIt first, ForwardIt last, OutputIt out_true, UnaryPredicate p) |
This is like a combination of partition_copy() and remove(). | |
template<typename ForwardRange , typename OutputIt , typename UnaryPredicate > | |
auto | partition_copy_remove (ForwardRange &&range, OutputIt out_true, UnaryPredicate p) |
template<typename ForwardRange , typename UnaryOperation > | |
auto | transform_in_place (ForwardRange &&range, UnaryOperation op) |
template<typename InputIterator , typename Proj = std::identity> | |
auto | min_value (InputIterator first, InputIterator last, Proj proj={}) |
template<typename InputRange , typename Proj = std::identity> | |
auto | min_value (InputRange &&range, Proj proj={}) |
template<typename InputIterator , typename Proj = std::identity> | |
auto | max_value (InputIterator first, InputIterator last, Proj proj={}) |
template<typename InputRange , typename Proj = std::identity> | |
auto | max_value (InputRange &&range, Proj proj={}) |
template<typename InputRange , typename Proj = std::identity> | |
constexpr auto | sum (InputRange &&range, Proj proj={}) |
template<typename T = void, typename Range > | |
auto | to_vector (Range &&range) -> std::vector< detail::ToVectorType< T, decltype(std::begin(range))> > |
template<typename T > | |
auto | to_vector (std::vector< T > &&v) |
template<typename... Ranges> | |
constexpr size_t | detail::sum_of_sizes (const Ranges &... ranges) |
template<typename Result > | |
void | detail::append (Result &) |
template<typename Result , typename Range , typename... Tail> | |
void | detail::append (Result &x, Range &&y, Tail &&... tail) |
template<typename Result , typename T2 , typename... Tail> | |
void | detail::append (Result &x, std::vector< T2 > &&y, Tail &&... tail) |
template<typename T , typename... Tail> | |
void | append (std::vector< T > &v, Tail &&... tail) |
template<typename T > | |
void | append (std::vector< T > &v, std::vector< T > &&range) |
template<typename T > | |
void | append (std::vector< T > &x, std::initializer_list< T > list) |
template<typename T = void, typename Range , typename... Tail> | |
auto | concat (const Range &range, Tail &&... tail) |
template<typename T , typename... Tail> | |
std::vector< T > | concat (std::vector< T > &&v, Tail &&... tail) |
template<typename T , size_t X, size_t Y> | |
constexpr auto | concatArray (const std::array< T, X > &x, const std::array< T, Y > &y) |
template<typename T , size_t X, size_t Y, size_t Z> | |
constexpr auto | concatArray (const std::array< T, X > &x, const std::array< T, Y > &y, const std::array< T, Z > &z) |
template<typename Key , typename Value , typename Key2 > | |
const Value * | lookup (const std::map< Key, Value > &m, const Key2 &k) |
template<typename Key , typename Value , typename Key2 > | |
Value * | lookup (std::map< Key, Value > &m, const Key2 &k) |
template<class... Ts> | |
overloaded (Ts...) -> overloaded< Ts... > | |
template<typename E > | |
constexpr auto | to_underlying (E e) noexcept |
void append | ( | std::vector< T > & | v, |
std::vector< T > && | range | ||
) |
void append | ( | std::vector< T > & | v, |
Tail &&... | tail | ||
) |
Definition at line 341 of file stl.hh.
References detail::append(), and detail::sum_of_sizes().
Referenced by concat(), concat(), and TEST_CASE().
void append | ( | std::vector< T > & | x, |
std::initializer_list< T > | list | ||
) |
auto concat | ( | const Range & | range, |
Tail &&... | tail | ||
) |
std::vector< T > concat | ( | std::vector< T > && | v, |
Tail &&... | tail | ||
) |
|
constexpr |
|
constexpr |
|
constexpr |
Definition at line 45 of file stl.hh.
References contains().
bool contains | ( | const RANGE & | range, |
const VAL & | val, | ||
Proj | proj | ||
) |
Definition at line 61 of file stl.hh.
References contains().
|
constexpr |
Check if a range contains a given value, using linear search.
Equivalent to 'find(first, last, val) != last', though this algorithm is more convenient to use. Note: we don't need a variant that uses 'find_if' instead of 'find' because STL already has the 'any_of' algorithm.
Definition at line 35 of file stl.hh.
Referenced by openmsx::MSXMultiIODevice::addDevice(), openmsx::Display::attach(), contains(), contains(), PerfectMinimalHash::create(), openmsx::getAllValuesFor(), openmsx::MSXMotherBoard::getUserName(), openmsx::MemoryOps::AllocMap::insert(), openmsx::FileContext::isUserContext(), openmsx::PersistentElementEnum< C >::load(), openmsx::matches(), openmsx::parseKeyChord(), openmsx::EventDistributor::registerEventListener(), openmsx::Mixer::registerMixer(), openmsx::ImGuiManager::registerPart(), openmsx::MachineMediaInfo::registerProvider(), openmsx::MSXDevice::testRemove(), and openmsx::MSXCPUInterface::testUnsetExpanded().
bool contains | ( | ITER | first, |
ITER | last, | ||
const VAL & | val, | ||
Proj | proj | ||
) |
|
constexpr |
Faster alternative to 'find_if' when it's guaranteed that the predicate will be true for at least one element in the given range.
See also 'find_unguarded'.
Definition at line 91 of file stl.hh.
Referenced by find_if_unguarded(), and rfind_if_unguarded().
|
constexpr |
Definition at line 101 of file stl.hh.
References find_if_unguarded().
ITER find_unguarded | ( | ITER | first, |
ITER | last, | ||
const VAL & | val, | ||
Proj | proj = {} |
||
) |
Faster alternative to 'find' when it's guaranteed that the value will be found (if not the behavior is undefined).
When asserts are enabled we check whether we really don't move beyond the end of the range. And this check is the only reason why you need to pass the 'last' parameter. Sometimes you see 'find_unguarded' without a 'last' parameter, we could consider providing such an overload as well.
Definition at line 75 of file stl.hh.
Referenced by openmsx::PostProcessor::paint(), openmsx::MSXCPUInterface::removeBreakPoint(), openmsx::Reactor::replaceBoard(), openmsx::HotKey::saveBindings(), openmsx::VideoSourceSetting::setSource(), openmsx::MSXMotherBoard::unregisterKeyboard(), and openmsx::MSXMixer::updateSoftwareVolume().
auto find_unguarded | ( | RANGE & | range, |
const VAL & | val, | ||
Proj | proj = {} |
||
) |
const Value * lookup | ( | const std::map< Key, Value > & | m, |
const Key2 & | k | ||
) |
Value * lookup | ( | std::map< Key, Value > & | m, |
const Key2 & | k | ||
) |
auto max_value | ( | InputIterator | first, |
InputIterator | last, | ||
Proj | proj = {} |
||
) |
Definition at line 227 of file stl.hh.
Referenced by openmsx::VideoSourceSetting::getSource(), and openmsx::MSXDevice::getVisibleMemRegion().
auto max_value | ( | InputRange && | range, |
Proj | proj = {} |
||
) |
auto min_value | ( | InputIterator | first, |
InputIterator | last, | ||
Proj | proj = {} |
||
) |
Definition at line 208 of file stl.hh.
Referenced by openmsx::MSXDevice::getVisibleMemRegion().
auto min_value | ( | InputRange && | range, |
Proj | proj = {} |
||
) |
void move_pop_back | ( | VECTOR & | v, |
typename VECTOR::iterator | it | ||
) |
Erase the pointed to element from the given vector.
We first move the last element into the indicated position and then pop the last element.
If the order of the elements in the vector is allowed to change this may be a faster alternative than calling 'v.erase(it)'.
Definition at line 137 of file stl.hh.
Referenced by openmsx::UserSettings::deleteSetting(), openmsx::Subject< T >::detach(), openmsx::Display::detach(), openmsx::MSXMotherBoard::freeUserName(), openmsx::TTFFontPool::release(), openmsx::ResampleCoeffs::releaseCoeffs(), openmsx::MemoryOps::AllocMap::remove(), openmsx::MSXMotherBoard::removeDevice(), openmsx::GlobalCliComm::removeListener(), openmsx::Debugger::removeProbeBreakPoint(), openmsx::Reactor::replaceBoard(), openmsx::EventDelay::sync(), openmsx::PluggingController::unregisterConnector(), openmsx::DiskManipulator::unregisterDrive(), openmsx::MSXEventDistributor::unregisterEventListener(), openmsx::MSXCPUInterface::unregisterGlobalRead(), openmsx::MSXCPUInterface::unregisterGlobalWrite(), openmsx::StateChangeDistributor::unregisterListener(), openmsx::Mixer::unregisterMixer(), openmsx::MachineMediaInfo::unregisterProvider(), openmsx::GlobalCommandController::unregisterProxySetting(), openmsx::MSXCommandController::unregisterSetting(), openmsx::MSXMixer::unregisterSound(), and openmsx::VideoSourceSetting::unregisterVideoSource().
overloaded | ( | Ts... | ) | -> overloaded< Ts... > |
std::pair< OutputIt, ForwardIt > partition_copy_remove | ( | ForwardIt | first, |
ForwardIt | last, | ||
OutputIt | out_true, | ||
UnaryPredicate | p | ||
) |
This is like a combination of partition_copy() and remove().
Each element is tested against the predicate. If it matches, the element is copied to the output and removed from the input. So the output contains all elements for which the predicate gives true and the input is modified in-place to contain the elements for which the predicate gives false. (Like the remove() algorithm, it's still required to call erase() to also shrink the input).
This algorithm returns a pair of iterators. -first: one past the matching elements (in the output range). Similar to the return value of the partition_copy() algorithm. -second: one past the non-matching elements (in the input range). Similar to the return value of the remove() algorithm.
Definition at line 172 of file stl.hh.
Referenced by partition_copy_remove().
auto partition_copy_remove | ( | ForwardRange && | range, |
OutputIt | out_true, | ||
UnaryPredicate | p | ||
) |
Definition at line 191 of file stl.hh.
References partition_copy_remove().
|
constexpr |
Definition at line 120 of file stl.hh.
References find_if_unguarded().
Referenced by openmsx::AfterCmd::removeSelf().
auto rfind_unguarded | ( | RANGE & | range, |
const VAL & | val, | ||
Proj | proj = {} |
||
) |
Similar to the find(_if)_unguarded functions above, but searches from the back to front.
Note that we only need to provide range versions. Because for the iterator versions it is already possible to pass reverse iterators.
Definition at line 112 of file stl.hh.
Referenced by openmsx::UserSettings::deleteSetting(), openmsx::OSDWidget::deleteWidget(), openmsx::Subject< T >::detach(), openmsx::Display::detach(), openmsx::MSXMotherBoard::freeUserName(), openmsx::TTFFontPool::release(), openmsx::ResampleCoeffs::releaseCoeffs(), openmsx::MSXMultiMemDevice::remove(), openmsx::MemoryOps::AllocMap::remove(), openmsx::MSXCPUInterface::removeCondition(), openmsx::MSXMotherBoard::removeDevice(), openmsx::MSXMultiIODevice::removeDevice(), openmsx::MSXMotherBoard::removeExtension(), openmsx::Display::removeLayer(), openmsx::GlobalCliComm::removeListener(), openmsx::Debugger::removeProbeBreakPoint(), openmsx::PluggingController::unregisterConnector(), openmsx::EventDistributor::unregisterEventListener(), openmsx::MSXEventDistributor::unregisterEventListener(), openmsx::MSXCPUInterface::unregisterGlobalRead(), openmsx::MSXCPUInterface::unregisterGlobalWrite(), openmsx::StateChangeDistributor::unregisterListener(), openmsx::MSXMapperIO::unregisterMapper(), openmsx::Mixer::unregisterMixer(), openmsx::MachineMediaInfo::unregisterProvider(), openmsx::Interpreter::unregisterSetting(), openmsx::MSXCommandController::unregisterSetting(), openmsx::MSXMixer::unregisterSound(), openmsx::VideoSourceSetting::unregisterVideoSource(), and openmsx::Display::updateZ().
|
constexpr |
Definition at line 248 of file stl.hh.
Referenced by openmsx::DiskManipulator::create(), openmsx::FilePoolCore::getSha1Sum(), openmsx::Paper::plot(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
|
constexprnoexcept |
Definition at line 468 of file stl.hh.
Referenced by openmsx::VDPAccessSlots::getAccessSlot(), openmsx::ImGuiMedia::loadLine(), openmsx::match(), openmsx::VDPAccessSlots::Calculator::next(), array_with_enum_index< Enum, T, S >::operator[](), array_with_enum_index< Enum, T, S >::operator[](), openmsx::YM2413Burczynski::Slot::setKeyOn(), openmsx::toString(), openmsx::toString(), and openmsx::AmdFlash::AutoSelect::validate().
auto to_vector | ( | Range && | range | ) | -> std::vector<detail::ToVectorType<T, decltype(std::begin(range))>> |
Definition at line 278 of file stl.hh.
Referenced by openmsx::MSXMultiMemDevice::getDevices(), openmsx::ImGuiTrainer::paint(), openmsx::CommandLineParser::parse(), openmsx::NowindHost::serialize(), openmsx::MSXCommandEvent::serialize(), openmsx::ImGuiMedia::showMenu(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and openmsx::Scheduler::~Scheduler().
auto to_vector | ( | std::vector< T > && | v | ) |
auto transform_in_place | ( | ForwardRange && | range, |
UnaryOperation | op | ||
) |
Definition at line 199 of file stl.hh.
Referenced by StringOp::toLower().