libzypp 17.38.7
ranges.h File Reference

Namespace routing for C++20 ranges and C++23 ranges::to<T>() backport. More...

#include <iterator>
#include <type_traits>
#include <zypp-core/ng/meta/type_traits.h>
#include <nanorange/nanorange.hpp>

Go to the source code of this file.

Classes

struct  zyppng::ranges::to_fn< Container >

Namespaces

namespace  zyppng
namespace  zyppng::_detail
namespace  zyppng::ranges
namespace  zyppng::ranges::detail

Typedefs

template<typename T>
using zyppng::ranges::detail::reserve_op = decltype( std::declval<T&>().reserve( std::declval<std::size_t>() ) )
template<typename T>
using zyppng::ranges::detail::size_op = decltype( std::declval<const T&>().size() )

Functions

template<typename Container, typename Range>
void zyppng::ranges::detail::maybe_reserve (Container &c, const Range &r)
template<typename Container, typename Range>
Container zyppng::ranges::to (Range &&range)
 Convert any range into a Container.
template<typename Container>
to_fn< Container > zyppng::ranges::to ()

Detailed Description

Namespace routing for C++20 ranges and C++23 ranges::to<T>() backport.

Consumers must always include this header and use zyppng::ranges:: rather than nano:: or std::ranges:: directly. This ensures a zero-touch migration to std::ranges once the compiler baseline supports it:

#include <zypp-core/ng/base/ranges.h>

auto result = myRange | zyppng::ranges::views::filter( pred ) | zyppng::ranges::views::transform( xform ) | zyppng::ranges::to<std::vector<Foo>>();

Do NOT include this header in legacy (non-ng/) code. Do NOT include <nanorange/nanorange.hpp> or <ranges> directly.

Definition in file ranges.h.