FE 0.9.0
Header-only C++ frontend library
Loading...
Searching...
No Matches
fe::StreamFn< F > Class Template Reference

Wrap a callable f(std::ostream&) -> std::ostream& so it streams via operator<< and std::format. More...

#include <fe/format.h>

Public Member Functions

constexpr StreamFn (F f)

Friends

std::ostream & operator<< (std::ostream &os, StreamFn const &s)

Detailed Description

template<class F>
requires std::invocable<const F&, std::ostream&>
class fe::StreamFn< F >

Wrap a callable f(std::ostream&) -> std::ostream& so it streams via operator<< and std::format.

Useful for inline ad-hoc formatting:

auto greet = fe::StreamFn{[](std::ostream& os) { os << "hi"; }};
std::cout << greet;
std::format("{}", greet);
Wrap a callable f(std::ostream&) -> std::ostream& so it streams via operator<< and std::format.
Definition format.h:29

Definition at line 29 of file format.h.

Constructor & Destructor Documentation

◆ StreamFn()

template<class F>
fe::StreamFn< F >::StreamFn ( F f)
inlineconstexpr

Definition at line 31 of file format.h.

Referenced by operator<<.

◆ operator<<

template<class F>
std::ostream & operator<< ( std::ostream & os,
StreamFn< F > const & s )
friend

Definition at line 34 of file format.h.

References StreamFn().


The documentation for this class was generated from the following file: