kblib 0.2.3
General utilities library for modern C++
|
This file provides some iterators, ranges, iterator/range adapters, and operations that can be performed on iterators or smart pointers. More...
#include "enumerate-contrib-cry.h"
#include "enumerate-contrib-tw.h"
#include "fakestd.h"
#include "traits.h"
#include <cassert>
#include <iterator>
#include <vector>
#include <optional>
Go to the source code of this file.
Namespaces | |
namespace | kblib |
The main namespace in which all entities from kblib are defined. | |
namespace | kblib::detail_iterators |
namespace | kblib::detail_enumerate |
namespace | std |
Functions | |
template<typename P > | |
constexpr auto | kblib::to_pointer (P &&p) noexcept -> auto * |
Gets a raw pointer out of any smart pointer or iterator you might pass in, without dereferencing it or relying on a get() method. More... | |
template<typename Container , typename Comp = std::less<value_type_linear_t<Container>>> | |
auto | kblib::max_element (Container &c, Comp comp) -> value_type_linear_t< Container > * |
template<typename C > | |
counting_back_insert_iterator< C > | kblib::counting_back_inserter (C &c, std::size_t count=0) |
template<typename T > | |
constexpr auto | kblib::operator+ (T val, adjuster a) noexcept -> enable_if_t< not detail_iterators::is_addable< T, std::ptrdiff_t >::value, decltype(std::advance(val, a.adj))> |
template<typename T > | |
constexpr auto | kblib::operator+ (T val, incrementer) -> T |
Increments val. More... | |
template<typename T > | |
constexpr auto | kblib::operator+ (T val, decrementer) -> T |
Decrements val. More... | |
template<typename Value , typename Delta = int> | |
constexpr auto | kblib::range (Value min, Value max, Delta step=0) -> range_t< Value, Delta > |
Constructs a range from beginning, end, and step amount. The range is half-open, that is min is in the range but max is not. If unspecified, the step is automatically either 1 or -1, depending on whether max > min. More... | |
template<typename Value > | |
constexpr auto | kblib::range (Value max) -> range_t< Value, incrementer > |
Constructs a half-open range [0, max). The step is automatically determined based on the sign of max. More... | |
template<typename Value , typename Delta = int> | |
constexpr auto | kblib::irange (Value, Value, Delta=0) |
template<typename T1 , typename T2 > | |
auto | kblib::detail_enumerate::get_or (T1 &&t1, T2 &&t2) -> decltype(auto) |
template<typename T > | |
auto | kblib::detail_enumerate::get_magic_ptr () -> T * |
template<std::size_t I, typename T > | |
auto | kblib::get (enumeration< T > &&e) -> decltype(auto) |
template<std::size_t I, typename T > | |
auto | kblib::get (const enumeration< T > &&e) -> decltype(auto) |
template<std::size_t I, typename T > | |
auto | kblib::get (volatile enumeration< T > &e) -> decltype(auto) |
template<std::size_t I, typename T > | |
auto | kblib::get (const volatile enumeration< T > &e) -> decltype(auto) |
template<typename It , typename EIt > | |
auto | kblib::magic_enumerate (It begin, EIt end) -> enumerator_t< It, EIt > |
Allow access to indexes while using range-based for loops. More... | |
template<typename Range > | |
auto | kblib::magic_enumerate (Range &&r) -> auto |
Allow access to indexes while using range-based for loops. Safe to use with rvalues. More... | |
template<typename Iter1 , typename Iter2 > | |
constexpr auto | kblib::indirect (Iter1 begin, Iter2 end) noexcept(noexcept(indirect_range< Iter1, Iter2 >{begin, end})) -> indirect_range< Iter1, Iter2 > |
Create a range from an iterator pair. Primarily useful for range-for loops. More... | |
template<typename Iter1 , typename Iter2 > | |
kblib::indirect_range (Iter1, Iter2) -> indirect_range< Iter1, Iter2 > | |
template<typename Iter1 , typename Iter2 > | |
auto | kblib::cry_enumerate (Iter1 begin, Iter2 end) -> auto |
template<typename It , typename operation > | |
kblib::transform_iterator (It, operation) -> transform_iterator< It, operation > | |
template<typename base_iterator , typename operation > | |
auto | kblib::make_transform_iterator (base_iterator it, operation op) noexcept(noexcept(transform_iterator< base_iterator, operation >{ it, std::move(op)})) -> transform_iterator< base_iterator, operation > |
Factory function to make transform_iterators. More... | |
template<typename base_iterator , typename operation > | |
auto | kblib::transformer (base_iterator it, operation op) noexcept(noexcept(transform_iterator< base_iterator, operation >{it, std::move(op)})) -> transform_iterator< base_iterator, operation > |
Factory function to make transform_iterators. More... | |
template<typename It , typename EndIt , typename operation > | |
auto | kblib::transform_range (It begin, EndIt end, operation op) noexcept(noexcept(indirect(transform_iterator{begin, op}, end))) -> auto |
template<typename InputIt1 , typename EndIt , typename InputIt2 > | |
auto | kblib::zip (InputIt1 begin1, EndIt end1, InputIt2 begin2) noexcept(zip_iterator< InputIt1, EndIt, InputIt2 >::is_nothrow_copyable) -> zip_iterator< InputIt1, EndIt, InputIt2 > |
Iterate over two ranges in lockstep, like Python's zip. More... | |
template<typename Range1 , typename Range2 > | |
auto | kblib::zip (Range1 &&r1, Range2 &&r2) noexcept(zip_iterator< decltype(begin(r1)), decltype(end(r1)), decltype(begin(r2))>::is_nothrow_copyable) -> zip_iterator< decltype(begin(r1)), decltype(end(r1)), decltype(begin(r2))> |
Iterate over two ranges in lockstep, like Python's zip. More... | |
template<typename F > | |
auto | kblib::consumer (F f) -> consume_iterator< F > |
Creates a consume_iterator of deduced type F. More... | |
This file provides some iterators, ranges, iterator/range adapters, and operations that can be performed on iterators or smart pointers.
Definition in file iterators.h.