microfmt
Zero-allocation C++ formatting for constrained environments
Loading...
Searching...
No Matches
Classes | Namespaces | Functions
filter_view.hpp File Reference

Format only the elements of a range that satisfy a predicate. More...

#include "../microfmt.hpp"
#include <cstddef>
#include <iterator>
#include <string_view>
#include <type_traits>
#include <utility>
Include dependency graph for filter_view.hpp:

Go to the source code of this file.

Classes

struct  microfmt::filtered_range_view< Range, Predicate >
 
struct  microfmt::filtered_pointer_range_view< T, Predicate >
 
struct  microfmt::formatter< filtered_range_view< Range, Predicate > >
 
struct  microfmt::formatter< filtered_pointer_range_view< T, Predicate > >
 

Namespaces

namespace  microfmt
 

Functions

template<typename Range , typename Predicate >
constexpr auto microfmt::filter (const Range &rng, Predicate &&pred) noexcept
 
template<typename Range , typename Predicate , std::enable_if_t<!std::is_lvalue_reference_v< Range >, int > = 0>
constexpr auto microfmt::filter (Range &&, Predicate &&) noexcept=delete
 
template<typename T , typename Predicate >
constexpr auto microfmt::filter (const T *ptr, size_t count, Predicate &&pred) noexcept
 

Detailed Description

Format only the elements of a range that satisfy a predicate.

Use microfmt::filter with an iterable range or a raw pointer and count. The view stores the predicate without allocation and evaluates it as output is formatted. Use b, c, or n to select square brackets, braces, or no outer delimiters; the remaining specifier is forwarded to each matching element.