fmt
Loading...
Searching...
No Matches
ostream.cppm File Reference
module fmt

Support for formatting into and from std::ostream. More...

#include "fmt/macros.hpp"
#include <cerrno>
#include <climits>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <version>
import fmt:chrono;
import std;

Classes

class  fmt::detail::FileAccess< Tag, BufType, FileMemberPtr >
struct  fmt::detail::StreamedView< T >
struct  fmt::BasicOstreamFormatter< Char >
struct  fmt::Formatter< detail::StreamedView< T >, Char >

Typedefs

using fmt::OstreamFormatter = BasicOstreamFormatter<char>

Functions

template<typename Char>
auto fmt::detail::writeBuffer (std::basic_ostream< Char > &os, Buffer< Char > &buf) -> void
template<typename T>
constexpr auto fmt::streamed (const T &value) -> detail::StreamedView< T >
auto fmt::vprint (std::ostream &os, StringView fmt, FormatArgs args) -> void
template<typename... T>
auto fmt::print (std::ostream &os, FormatString< T... > fmt, T &&... args) -> void
template<typename... T>
auto fmt::println (std::ostream &os, FormatString< T... > fmt, T &&... args) -> void

Detailed Description

Support for formatting into and from std::ostream.

Interface partition fmt:ostream.

Typedef Documentation

◆ OstreamFormatter

using fmt::OstreamFormatter = BasicOstreamFormatter<char>

basic_ostream_formatter for char.

Function Documentation

◆ print()

template<typename... T>
auto fmt::print ( std::ostream & os,
FormatString< T... > fmt,
T &&... args ) -> void
export

Prints formatted data to the stream os.

Example:

fmt::print(cerr, "Don't {}!", "panic");

◆ println()

template<typename... T>
auto fmt::println ( std::ostream & os,
FormatString< T... > fmt,
T &&... args ) -> void
export

Prints formatted data to the stream os, followed by a newline.

Example:

fmt::println(cerr, "Don't {}!", "panic");

◆ streamed()

template<typename T>
auto fmt::streamed ( const T & value) -> detail::StreamedView< T >
constexpr

Returns a view that formats value via an ostream operator<<.

Example:

fmt::print("Current thread id: {}\n",
           fmt::streamed(std::this_thread::get_id()));

◆ vprint()

auto fmt::vprint ( std::ostream & os,
StringView fmt,
FormatArgs args ) -> void

Writes the already-formatted arguments args to the stream os.

This is the type-erased form of print: it takes FormatArgs rather than a parameter pack, so it can be called from a function that is not itself a template. On Windows a stream backed by a console is written to directly, so that Unicode is preserved.

◆ writeBuffer()

template<typename Char>
auto fmt::detail::writeBuffer ( std::basic_ostream< Char > & os,
Buffer< Char > & buf ) -> void

Writes the content of buf to os, in chunks no larger than std::streamsize can express.

A separate function rather than a part of vprint to simplify testing.