openMSX
|
#include <cstddef>
#include <iterator>
#include <tuple>
#include <utility>
Go to the source code of this file.
Functions | |
template<typename Iterable , typename Iter = decltype(std::begin(std::declval<Iterable>())), typename = decltype(std::end (std::declval<Iterable>()))> | |
constexpr auto | enumerate (Iterable &&iterable) |
Heavily inspired by Nathan Reed's blog post: Python-Like enumerate() In C++17 http://reedbeta.com/blog/python-like-enumerate-in-cpp17/. | |
|
constexpr |
Heavily inspired by Nathan Reed's blog post: Python-Like enumerate() In C++17 http://reedbeta.com/blog/python-like-enumerate-in-cpp17/.
Can be used to simplify loops like: for (size_t i = 0; i < std::size(my_array); ++i) { auto& elem = my_array[i]; ... do stuff with 'i' and 'elem' }
With enumerate() that becomes: for (auto [i, elem] : enumerate(my_array)) { ... do stuff with 'i' and 'elem' }
Definition at line 28 of file enumerate.hh.
References begin(), end(), operator*(), and operator==().
Referenced by openmsx::AviRecorder::addWave(), openmsx::ColecoJoystickIO::ColecoJoystickIO(), openmsx::JoyTap::createPorts(), openmsx::NowindCommand::execute(), openmsx::DiskImageUtils::partition(), openmsx::V9990SDLRasterizer::preCalcPalettes(), openmsx::RawTrack::readBlock(), openmsx::SectorAccessibleDisk::readSectorsImpl(), openmsx::MSXMixer::registerSound(), openmsx::MegaFlashRomSCCPlusSD::reset(), openmsx::MusicalMemoryMapper::reset(), openmsx::ImGuiOsdIcons::save(), openmsx::Shortcuts::saveShortcuts(), openmsx::MSXFDC::serialize(), openmsx::MB89352::serialize(), openmsx::WD33C93::serialize(), openmsx::JoyTap::serialize(), openmsx::MSXMapperIO::serialize(), openmsx::RomHolyQuran2::serialize(), openmsx::MSXS1985::serialize(), openmsx::I8254::serialize(), openmsx::MSXSCCPlusCart::serialize(), openmsx::SCC::serialize(), openmsx::YM2413Okazaki::YM2413::serialize(), openmsx::YMF278::serialize(), TEST_CASE(), TEST_CASE(), openmsx::YM2413Okazaki::Slot::updatePG(), openmsx::Wav16Writer::write(), openmsx::NinjaTap::write(), openmsx::RawTrack::writeBlock(), openmsx::SectorAccessibleDisk::writeSectors(), and ProfileCounters< ENABLED, ENUM >::~ProfileCounters().