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

Formatting of built-in types: integers, floating point, strings and pointers, with the buffer and presentation-spec machinery behind them. More...

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

Classes

struct  std::iterator_traits< fmt::BasicAppender< T > >
struct  fmt::IsContiguous< std::basic_string< Char, Traits, Allocator > >
struct  fmt::detail::StringLiteral< Char, C >
class  fmt::detail::Uint128
struct  fmt::detail::IsIntegral< T >
struct  fmt::detail::IsIntegral< NativeInt128 >
struct  fmt::detail::IsIntegral< uint128_t >
struct  fmt::detail::Float128
struct  fmt::detail::IsFloatingPoint< T >
struct  fmt::detail::IsFloatingPoint< Float128 >
struct  fmt::detail::Allocator< T, bool >
class  fmt::BasicMemoryBuffer< T, SIZE, Allocator >
class  fmt::Writer
class  fmt::StringBuffer
struct  fmt::IsContiguous< BasicMemoryBuffer< T, SIZE, Allocator > >
class  fmt::FormatError
struct  fmt::detail::FixedString< Char, N >
struct  fmt::detail::ThousandsSepResult< Char >
class  fmt::detail::Utf8ToUtf16
class  fmt::detail::ToUtf8< WChar, Buffer >
struct  fmt::detail::dragonbox::FloatInfo< float >
struct  fmt::detail::dragonbox::FloatInfo< double >
struct  fmt::detail::dragonbox::FloatInfo< T, enable_if_t< std::numeric_limits< T >::digits==64||std::numeric_limits< T >::digits==113||IsFloat128< T >::value > >
struct  fmt::detail::dragonbox::FloatInfo< T, enable_if_t< IsDoubleDouble< T >::value > >
struct  fmt::detail::dragonbox::DecimalFp< T >
struct  fmt::detail::BasicFp< F >
struct  fmt::detail::FindEscapeResult< Char >
class  fmt::detail::DigitGrouping< Char >
struct  fmt::detail::WriteIntArg< UInt >
struct  fmt::detail::LocWriter< Char >
struct  fmt::detail::SizePadding
struct  fmt::detail::BigDecimalFp
class  fmt::detail::FallbackDigitGrouping< Char >
struct  fmt::detail::HasIsfinite< T, Enable >
struct  fmt::detail::HasIsfinite< T, enable_if_t< sizeof(std::isfinite(T())) !=0 > >
class  fmt::detail::Bigint
struct  fmt::detail::DefaultArgFormatter< Char >
struct  fmt::detail::ArgFormatter< Char >
struct  fmt::detail::DynamicSpecGetter
struct  fmt::detail::StaticNamedArg< T, Char, N, Str >
struct  fmt::detail::IsNamedArg< StaticNamedArg< T, Char, N, Str > >
struct  fmt::detail::IsStaticNamedArg< StaticNamedArg< T, Char, N, Str > >
struct  fmt::detail::UdlArg< Char, N, Str >
struct  fmt::detail::FormatHandler< Char >
class  fmt::GenericContext< OutputIt, Char >
class  fmt::LocValue
class  fmt::FormatFacet< Locale >
struct  fmt::Formatter< Char[N], Char >
class  fmt::Formatter< std::basic_string< Char, Traits, Allocator >, Char >
struct  fmt::Formatter< detail::Float128, Char >
struct  fmt::Formatter< T, Char, void_t< detail::FormatAsResult< T > > >
struct  fmt::Bytes
struct  fmt::Formatter< Bytes >
struct  fmt::GroupDigitsView< T >
struct  fmt::Formatter< GroupDigitsView< T > >
struct  fmt::NestedView< T, Char >
struct  fmt::Formatter< NestedView< T, Char >, Char >
struct  fmt::NestedFormatter< T, Char >
class  fmt::FormatInt

Namespaces

namespace  fmt::literals

Typedefs

template<typename Char>
using fmt::detail::StdStringView = std::basic_string_view<Char>
using fmt::detail::uint128_t = conditional_t<FMT_USE_INT128, NativeUint128, Uint128>
using fmt::detail::uintptr_t = uint128_t
template<typename OutputIt>
using fmt::detail::ReserveIterator
template<typename T>
using fmt::detail::IsSigned
template<typename T>
using fmt::detail::IsInteger
template<typename T>
using fmt::detail::IsFloat128 = std::is_same<T, Float128>
using fmt::MemoryBuffer = BasicMemoryBuffer<char>
template<typename T>
using fmt::detail::uint32_or_64_or_128_t
template<typename T>
using fmt::detail::uint64_or_128_t
using fmt::detail::Fp = BasicFp<Ullong>
template<typename T, bool doublish = numBits<T>() == numBits<double>()>
using fmt::detail::ConvertFloatResult
template<typename T>
using fmt::detail::IsBuiltin
using fmt::detail::FormatFunc = void (*)(detail::Buffer<char>&, int, const char*)

Enumerations

enum class  ToUtf8ErrorPolicy : int { kAbort = 0 , kReplace = 1 , kWtf = 2 }
enum class  Dragon : unsigned { kNone = 0 , kPredecessorCloser = 1 , kFixup = 2 , kFixed = 4 }

Functions

template<typename To, typename From>
requires (sizeof(To) == sizeof(From))
constexpr auto fmt::detail::bitCast (const From &from) -> To
auto fmt::detail::isBigEndian () -> bool
template<typename T>
constexpr auto fmt::detail::maxValue () -> T
template<typename T>
constexpr auto fmt::detail::numBits () -> int
template<>
constexpr auto fmt::detail::numBits< NativeInt128 > () -> int
template<>
constexpr auto fmt::detail::numBits< NativeUint128 > () -> int
template<>
constexpr auto fmt::detail::numBits< Uint128 > () -> int
template<typename To, typename From>
requires (sizeof(To) > sizeof(From))
auto fmt::detail::bitCast (const From &from) -> To
constexpr auto fmt::detail::countlZero (uint32_t n) -> int
constexpr auto fmt::detail::countlZero (uint64_t n) -> int
auto fmt::detail::assume (bool condition) -> void
template<typename OutputIt>
requires (IsBackInsertIterator<OutputIt>::value && IsContiguous<typename OutputIt::container>::value)
constexpr auto fmt::detail::reserve (OutputIt it, size_t n) -> typename OutputIt::value_type *
template<typename T>
constexpr auto fmt::detail::reserve (BasicAppender< T > it, size_t n) -> BasicAppender< T >
template<typename Iterator>
constexpr auto fmt::detail::reserve (Iterator &it, size_t) -> Iterator &
template<typename T, typename OutputIt>
constexpr auto fmt::detail::toPointer (OutputIt, size_t) -> T *
template<typename T>
constexpr auto fmt::detail::toPointer (T *&ptr, size_t n) -> T *
template<typename T>
constexpr auto fmt::detail::toPointer (BasicAppender< T > it, size_t n) -> T *
template<typename OutputIt>
requires (IsBackInsertIterator<OutputIt>::value && IsContiguous<typename OutputIt::container>::value)
auto fmt::detail::baseIterator (OutputIt it, typename OutputIt::container_type::value_type *) -> OutputIt
template<typename Iterator>
constexpr auto fmt::detail::baseIterator (Iterator, Iterator it) -> Iterator
template<typename OutputIt, typename Size, typename T>
constexpr auto fmt::detail::fill_n (OutputIt out, Size count, const T &value) -> OutputIt
template<typename T, typename Size>
constexpr auto fmt::detail::fill_n (T *out, Size count, char value) -> T *
template<typename T, typename V, typename OutputIt>
constexpr auto fmt::detail::copy (BasicStringView< V > s, OutputIt out) -> OutputIt
template<typename OutChar, typename InputIt, typename OutputIt>
constexpr auto fmt::detail::copyNoinline (InputIt begin, InputIt end, OutputIt out) -> OutputIt
constexpr auto fmt::detail::utf8Decode (const char *s, uint32_t *c, int *e) -> const char *
template<typename F>
constexpr auto fmt::detail::forEachCodepoint (StringView s, F f) -> void
constexpr auto fmt::detail::displayWidthOf (uint32_t cp) noexcept -> size_t
template<typename Formatter>
constexpr auto fmt::detail::maybeSetDebugFormat (Formatter &f, bool set) -> decltype(f.setDebugFormat(set))
template<typename Formatter>
constexpr auto fmt::detail::maybeSetDebugFormat (Formatter &,...) -> void
template<size_t SIZE>
auto fmt::to_string (const BasicMemoryBuffer< char, SIZE > &buf) -> std::string
auto fmt::detail::writeConsole (int fd, StringView text) -> bool
auto fmt::detail::print (FILE *, StringView) -> void
template<typename Char, size_t N>
constexpr auto fmt::detail::compileStringToView (const Char(&s)[N]) -> BasicStringView< Char >
template<typename Char>
constexpr auto fmt::detail::compileStringToView (BasicStringView< Char > s) -> BasicStringView< Char >
template<typename T>
requires (IsSigned<T>::value)
constexpr auto fmt::detail::isNegative (T value) -> bool
template<typename T>
requires (!IsSigned<T>::value)
constexpr auto fmt::detail::isNegative (T) -> bool
auto fmt::detail::digits2 (size_t value) noexcept -> const char *
auto fmt::detail::digits2I (size_t value) noexcept -> const char *
template<typename Char>
constexpr auto fmt::detail::getsign (Sign s) -> Char
template<typename T>
constexpr auto fmt::detail::countDigitsFallback (T n) -> int
constexpr auto fmt::detail::digitsInc (uint64_t n) -> uint64_t
auto fmt::detail::doCountDigits (uint64_t n) -> int
constexpr auto fmt::detail::countDigits (uint64_t n) -> int
template<int BITS, typename UInt>
constexpr auto fmt::detail::countDigits (UInt n) -> int
auto fmt::detail::doCountDigits (uint32_t n) -> int
constexpr auto fmt::detail::countDigits (uint32_t n) -> int
template<typename Int>
constexpr auto fmt::detail::digits10 () noexcept -> int
template<>
constexpr auto fmt::detail::digits10< NativeInt128 > () noexcept -> int
template<>
constexpr auto fmt::detail::digits10< uint128_t > () noexcept -> int
template<typename Char>
auto fmt::detail::thousandsSepImpl (LocaleRef loc) -> ThousandsSepResult< Char >
template<typename Char>
auto fmt::detail::thousandsSep (LocaleRef loc) -> ThousandsSepResult< Char >
template<>
auto fmt::detail::thousandsSep (LocaleRef loc) -> ThousandsSepResult< wchar_t >
template<typename Char>
auto fmt::detail::decimalPointImpl (LocaleRef loc) -> Char
template<typename Char>
auto fmt::detail::decimalPoint (LocaleRef loc) -> Char
template<>
auto fmt::detail::decimalPoint (LocaleRef loc) -> wchar_t
template auto fmt::detail::thousandsSepImpl< char > (LocaleRef) -> ThousandsSepResult< char >
template auto fmt::detail::thousandsSepImpl< wchar_t > (LocaleRef) -> ThousandsSepResult< wchar_t >
template auto fmt::detail::decimalPointImpl (LocaleRef) -> char
template<typename Char>
auto fmt::detail::equal2 (const Char *lhs, const char *rhs) -> bool
auto fmt::detail::equal2 (const char *lhs, const char *rhs) -> bool
template<typename Char>
constexpr auto fmt::detail::write2digits (Char *out, size_t value) -> void
template<typename Char>
auto fmt::detail::write2digitsI (Char *out, size_t value) -> void
template<typename Char, typename UInt>
constexpr auto fmt::detail::doFormatDecimal (Char *out, UInt value, int size) -> Char *
template<typename Char, typename UInt>
constexpr auto fmt::detail::formatDecimal (Char *out, UInt value, int num_digits) -> Char *
template<typename Char, typename UInt, typename OutputIt>
requires (!std::is_pointer<remove_cvref_t<OutputIt>>::value)
constexpr auto fmt::detail::formatDecimal (OutputIt out, UInt value, int num_digits) -> OutputIt
template<typename Char, typename UInt>
constexpr auto fmt::detail::doFormatBase2e (int base_bits, Char *out, UInt value, int size, bool upper=false) -> Char *
template<typename Char, typename UInt>
constexpr auto fmt::detail::formatBase2e (int base_bits, Char *out, UInt value, int num_digits, bool upper=false) -> Char *
template<typename Char, typename OutputIt, typename UInt>
requires (IsBackInsertIterator<OutputIt>::value)
constexpr auto fmt::detail::formatBase2e (int base_bits, OutputIt out, UInt value, int num_digits, bool upper=false) -> OutputIt
auto fmt::detail::toUtf83bytes (Buffer< char > &buf, uint32_t cp) -> void
auto fmt::detail::umul128 (uint64_t x, uint64_t y) noexcept -> Uint128
auto fmt::detail::dragonbox::floorLog10Pow2 (int e) noexcept -> int
auto fmt::detail::dragonbox::floorLog2Pow10 (int e) noexcept -> int
auto fmt::detail::dragonbox::umul128Upper64 (uint64_t x, uint64_t y) noexcept -> uint64_t
auto fmt::detail::dragonbox::umul192Upper128 (uint64_t x, Uint128 y) noexcept -> Uint128
auto fmt::detail::dragonbox::getCachedPower (int k) noexcept -> Uint128
template<typename T>
auto fmt::detail::dragonbox::toDecimal (T x) noexcept -> DecimalFp< T >
template<typename Float>
constexpr auto fmt::detail::hasImplicitBit () -> bool
template<typename Float>
constexpr auto fmt::detail::numSignificandBits () -> int
template<typename Float>
constexpr auto fmt::detail::exponentMask () -> typename dragonbox::FloatInfo< Float >::CarrierUint
template<typename Float>
constexpr auto fmt::detail::exponentBias () -> int
constexpr auto fmt::detail::computeExpSize (int exp) -> int
template<typename Char, typename OutputIt>
constexpr auto fmt::detail::writeExponent (int exp, OutputIt out) -> OutputIt
template<int SHIFT = 0, typename F>
constexpr auto fmt::detail::normalize (BasicFp< F > value) -> BasicFp< F >
constexpr auto fmt::detail::multiply (uint64_t lhs, uint64_t rhs) -> uint64_t
constexpr auto fmt::detail::operator* (Fp x, Fp y) -> Fp
template<typename T>
constexpr auto fmt::detail::convertFloat (T value) -> ConvertFloatResult< T >
template<bool C, typename T, typename F>
requires (C)
auto fmt::detail::select (T true_value, F) -> T
template<bool C, typename T, typename F>
requires (!C)
auto fmt::detail::select (T, F false_value) -> F
template<typename Char, typename OutputIt>
constexpr auto fmt::detail::fill (OutputIt it, size_t n, const BasicSpecs &specs) -> OutputIt
template<typename Char, Align default_align = Align::kLeft, typename OutputIt, typename F>
constexpr auto fmt::detail::writePadded (OutputIt out, const FormatSpecs &specs, size_t size, size_t width, F &&f) -> OutputIt
template<typename Char, Align default_align = Align::kLeft, typename OutputIt, typename F>
constexpr auto fmt::detail::writePadded (OutputIt out, const FormatSpecs &specs, size_t size, F &&f) -> OutputIt
template<typename Char, Align default_align = Align::kLeft, typename OutputIt>
constexpr auto fmt::detail::writeBytes (OutputIt out, StringView bytes, const FormatSpecs &specs={}) -> OutputIt
template<typename Char, typename OutputIt, typename UIntPtr>
auto fmt::detail::writePtr (OutputIt out, UIntPtr value, const FormatSpecs *specs) -> OutputIt
auto fmt::detail::isPrintable (uint32_t cp) -> bool
auto fmt::detail::needsEscape (uint32_t cp) -> bool
template<typename Char>
auto fmt::detail::findEscape (const Char *begin, const Char *end) -> FindEscapeResult< Char >
auto fmt::detail::findEscape (const char *begin, const char *end) -> FindEscapeResult< char >
template<size_t width, typename Char, typename OutputIt>
auto fmt::detail::writeCodepoint (OutputIt out, char prefix, uint32_t cp) -> OutputIt
template<typename OutputIt, typename Char>
auto fmt::detail::writeEscapedCp (OutputIt out, const FindEscapeResult< Char > &escape) -> OutputIt
template<typename Char, typename OutputIt>
auto fmt::detail::writeEscapedString (OutputIt out, BasicStringView< Char > str) -> OutputIt
template<typename Char, typename OutputIt>
auto fmt::detail::writeEscapedChar (OutputIt out, Char v) -> OutputIt
template<typename Char, typename OutputIt>
constexpr auto fmt::detail::writeChar (OutputIt out, Char value, const FormatSpecs &specs) -> OutputIt
constexpr auto fmt::detail::prefixAppend (unsigned &prefix, unsigned value) -> void
template<typename Char, typename OutputIt, typename UInt>
constexpr auto fmt::detail::writeIntChr (OutputIt out, UInt abs_value, bool negative, const FormatSpecs &specs) -> OutputIt
template<typename OutputIt, typename UInt, typename Char>
auto fmt::detail::writeInt (OutputIt out, UInt value, unsigned prefix, const FormatSpecs &specs, const DigitGrouping< Char > &grouping) -> OutputIt
template<typename OutputIt>
auto fmt::detail::writeLoc (OutputIt, const LocValue &, const FormatSpecs &, LocaleRef) -> bool
template<typename T>
constexpr auto fmt::detail::makeWriteIntArg (T value, Sign s) -> WriteIntArg< uint32_or_64_or_128_t< T > >
template<typename Char, typename OutputIt, typename T>
constexpr auto fmt::detail::writeInt (OutputIt out, WriteIntArg< T > arg, const FormatSpecs &specs) -> OutputIt
template<typename Char, typename OutputIt, typename T>
constexpr auto fmt::detail::writeIntNoinline (OutputIt out, WriteIntArg< T > arg, const FormatSpecs &specs) -> OutputIt
template<typename Char, typename OutputIt, typename T>
requires (IsIntegral<T>::value && !std::is_same<T, bool>::value && !std::is_same<T, Char>::value)
constexpr auto fmt::detail::write (OutputIt out, T value, const FormatSpecs &specs, LocaleRef loc) -> OutputIt
template<typename Char, typename OutputIt>
constexpr auto fmt::detail::write (OutputIt out, Char value, const FormatSpecs &specs, LocaleRef loc={}) -> OutputIt
template<typename Char, typename OutputIt>
requires (std::is_same<Char, char>::value)
constexpr auto fmt::detail::write (OutputIt out, BasicStringView< Char > s, const FormatSpecs &specs) -> OutputIt
template<typename Char, typename OutputIt>
requires (!std::is_same<Char, char>::value)
constexpr auto fmt::detail::write (OutputIt out, BasicStringView< Char > s, const FormatSpecs &specs) -> OutputIt
template<typename Char, typename OutputIt>
constexpr auto fmt::detail::write (OutputIt out, BasicStringView< Char > s, const FormatSpecs &specs, LocaleRef) -> OutputIt
template<typename Char, typename OutputIt>
constexpr auto fmt::detail::write (OutputIt out, const Char *s, const FormatSpecs &specs, LocaleRef) -> OutputIt
template<typename Char, typename OutputIt, typename T>
requires (IsIntegral<T>::value && !std::is_same<T, bool>::value && !std::is_same<T, Char>::value)
constexpr auto fmt::detail::write (OutputIt out, T value) -> OutputIt
template<typename Char>
constexpr auto fmt::detail::parseAlign (const Char *begin, const Char *end, FormatSpecs &specs) -> const Char *
template<typename Char, typename OutputIt>
constexpr auto fmt::detail::writeNonfinite (OutputIt out, bool isnan, FormatSpecs specs, Sign s) -> OutputIt
constexpr auto fmt::detail::getSignificandSize (const BigDecimalFp &f) -> int
template<typename T>
auto fmt::detail::getSignificandSize (const dragonbox::DecimalFp< T > &f) -> int
template<typename Char, typename OutputIt>
constexpr auto fmt::detail::writeSignificand (OutputIt out, const char *significand, int significand_size) -> OutputIt
template<typename Char, typename OutputIt, typename UInt>
auto fmt::detail::writeSignificand (OutputIt out, UInt significand, int significand_size) -> OutputIt
template<typename Char, typename OutputIt, typename T, typename Grouping>
constexpr auto fmt::detail::writeSignificand (OutputIt out, T significand, int significand_size, int exponent, const Grouping &grouping) -> OutputIt
template<typename Char, typename UInt>
requires (std::is_integral<UInt>::value)
auto fmt::detail::writeSignificand (Char *out, UInt significand, int significand_size, int integral_size, Char decimal_point) -> Char *
template<typename OutputIt, typename UInt, typename Char>
requires (!std::is_pointer<remove_cvref_t<OutputIt>>::value)
auto fmt::detail::writeSignificand (OutputIt out, UInt significand, int significand_size, int integral_size, Char decimal_point) -> OutputIt
template<typename OutputIt, typename Char>
constexpr auto fmt::detail::writeSignificand (OutputIt out, const char *significand, int significand_size, int integral_size, Char decimal_point) -> OutputIt
template<typename OutputIt, typename Char, typename T, typename Grouping>
constexpr auto fmt::detail::writeSignificand (OutputIt out, T significand, int significand_size, int integral_size, Char decimal_point, const Grouping &grouping) -> OutputIt
template<typename T>
consteval auto fmt::detail::expUpper () -> int
constexpr auto fmt::detail::useFixed (int exp, int exp_upper) -> bool
template<typename Char, typename Grouping, typename OutputIt, typename DecimalFP>
constexpr auto fmt::detail::writeFixed (OutputIt out, const DecimalFP &f, int significand_size, Char decimal_point, const FormatSpecs &specs, Sign s, LocaleRef loc={}) -> OutputIt
template<typename Char, typename Grouping, typename OutputIt, typename DecimalFP>
constexpr auto fmt::detail::doWriteFloat (OutputIt out, const DecimalFP &f, const FormatSpecs &specs, Sign s, int exp_upper, LocaleRef loc) -> OutputIt
template<typename Char, typename OutputIt, typename DecimalFP>
constexpr auto fmt::detail::writeFloat (OutputIt out, const DecimalFP &f, const FormatSpecs &specs, Sign s, int exp_upper, LocaleRef loc) -> OutputIt
template<typename T>
constexpr auto fmt::detail::isnan (T value) -> bool
template<typename T>
requires (IsFloatingPoint<T>::value && HasIsfinite<T>::value)
constexpr auto fmt::detail::isfinite (T value) -> bool
template<typename T>
requires (!HasIsfinite<T>::value)
constexpr auto fmt::detail::isfinite (T value) -> bool
template<typename T>
requires (IsFloatingPoint<T>::value)
constexpr auto fmt::detail::signbit (T value) -> bool
constexpr auto fmt::detail::adjustPrecision (int &precision, int exp10) -> void
constexpr auto fmt::detail::operator| (Dragon lhs, Dragon rhs) -> Dragon
constexpr auto fmt::detail::hasFlag (Dragon flags, Dragon flag) -> bool
constexpr auto fmt::detail::formatDragon (BasicFp< uint128_t > value, Dragon flags, int num_digits, Buffer< char > &buf, int &exp10) -> void
template<typename Float>
requires (!IsDoubleDouble<Float>::value)
constexpr auto fmt::detail::formatHexfloat (Float value, FormatSpecs specs, Buffer< char > &buf) -> void
template<typename Float>
requires (IsDoubleDouble<Float>::value)
constexpr auto fmt::detail::formatHexfloat (Float value, FormatSpecs specs, Buffer< char > &buf) -> void
constexpr auto fmt::detail::fractionalPartRoundingThresholds (int index) -> uint32_t
template<typename Float>
constexpr auto fmt::detail::formatFloat (Float value, int precision, const FormatSpecs &specs, bool binary32, Buffer< char > &buf) -> int
template<typename Char, typename OutputIt, typename T>
requires (IsFloatingPoint<T>::value)
constexpr auto fmt::detail::write (OutputIt out, T value, FormatSpecs specs, LocaleRef loc={}) -> OutputIt
template<typename Char, typename OutputIt, typename T>
requires (IsFastFloat<T>::value)
constexpr auto fmt::detail::write (OutputIt out, T value) -> OutputIt
template<typename Char, typename OutputIt, typename T>
requires (IsFloatingPoint<T>::value && !IsFastFloat<T>::value)
auto fmt::detail::write (OutputIt out, T value) -> OutputIt
template<typename Char, typename OutputIt>
auto fmt::detail::write (OutputIt out, Monostate, FormatSpecs={}, LocaleRef={}) -> OutputIt
template<typename Char, typename OutputIt>
constexpr auto fmt::detail::write (OutputIt out, BasicStringView< Char > value) -> OutputIt
template<typename Char, typename OutputIt, typename T>
requires (HasToStringView<T>::value)
constexpr auto fmt::detail::write (OutputIt out, const T &value) -> OutputIt
template<typename Char, typename OutputIt, typename T>
requires (std::is_enum<T>::value && !std::is_same<T, Char>::value && MappedTypeConstant<T, Char>::value != Type::kCustomType)
constexpr auto fmt::detail::write (OutputIt out, T value) -> OutputIt
template<typename Char, typename OutputIt, typename T>
requires (std::is_same<T, bool>::value)
constexpr auto fmt::detail::write (OutputIt out, T value, const FormatSpecs &specs={}, LocaleRef={}) -> OutputIt
template<typename Char, typename OutputIt>
constexpr auto fmt::detail::write (OutputIt out, Char value) -> OutputIt
template<typename Char, typename OutputIt>
constexpr auto fmt::detail::write (OutputIt out, const Char *value) -> OutputIt
template<typename Char, typename OutputIt, typename T>
requires (std::is_same<T, void>::value)
auto fmt::detail::write (OutputIt out, const T *value, const FormatSpecs &specs={}, LocaleRef={}) -> OutputIt
template<typename Char, typename OutputIt, typename T>
requires (MappedTypeConstant<T, Char>::value == Type::kCustomType && !std::is_fundamental<T>::value)
constexpr auto fmt::detail::write (OutputIt out, const T &value) -> OutputIt
template<typename Context>
constexpr auto fmt::detail::handleDynamicSpec (ArgIdKind kind, int &value, const arg_ref< typename Context::char_type > &ref, Context &ctx) -> void
auto fmt::detail::doReportError (FormatFunc func, int error_code, const char *message) noexcept -> void
auto fmt::detail::formatErrorCode (Buffer< char > &out, int error_code, StringView message) noexcept -> void
 fmt::FMT_FORMAT_AS (signed char, int)
 fmt::FMT_FORMAT_AS (unsigned char, unsigned)
 fmt::FMT_FORMAT_AS (short, int)
 fmt::FMT_FORMAT_AS (unsigned short, unsigned)
 fmt::FMT_FORMAT_AS (long, detail::LongType)
 fmt::FMT_FORMAT_AS (unsigned long, detail::UlongType)
 fmt::FMT_FORMAT_AS (Char *, const Char *)
 fmt::FMT_FORMAT_AS (detail::StdStringView< Char >, BasicStringView< Char >)
 fmt::FMT_FORMAT_AS (std::nullptr_t, const void *)
 fmt::FMT_FORMAT_AS (void *, const void *)
template<typename T>
auto fmt::ptr (T p) -> const void *
template<typename Enum>
constexpr auto fmt::underlying (Enum e) noexcept -> underlying_t< Enum >
template<typename Enum>
requires (std::is_enum<Enum>::value)
constexpr auto fmt::enums::formatAs (Enum e) noexcept -> underlying_t< Enum >
template<typename T>
auto fmt::groupDigits (T value) -> GroupDigitsView< T >
template<detail::FixedString S>
constexpr auto fmt::literals::operator""_a ()
auto fmt::vsystemError (int error_code, StringView fmt, FormatArgs args) -> std::system_error
template<typename... T>
auto fmt::systemError (int error_code, FormatString< T... > fmt, T &&... args) -> std::system_error
auto fmt::formatSystemError (detail::Buffer< char > &out, int error_code, const char *message) noexcept -> void
auto fmt::reportSystemError (int error_code, const char *message) noexcept -> void
auto fmt::vformat (LocaleRef loc, StringView fmt, FormatArgs args) -> std::string
template<typename... T>
auto fmt::format (LocaleRef loc, FormatString< T... > fmt, T &&... args) -> std::string
template<typename OutputIt>
requires (detail::IsOutputIterator<OutputIt, char>::value)
auto fmt::vformatTo (OutputIt out, LocaleRef loc, StringView fmt, FormatArgs args) -> OutputIt
template<typename OutputIt, typename... T>
requires (detail::IsOutputIterator<OutputIt, char>::value)
auto fmt::formatTo (OutputIt out, LocaleRef loc, FormatString< T... > fmt, T &&... args) -> OutputIt
template<typename... T>
auto fmt::formattedSize (LocaleRef loc, FormatString< T... > fmt, T &&... args) -> size_t
auto fmt::vformat (StringView fmt, FormatArgs args) -> std::string
template<typename... T>
auto fmt::format (FormatString< T... > fmt, T &&... args) -> std::string
template<typename T>
requires (std::is_integral<T>::value)
constexpr auto fmt::to_string (T value) -> std::string
template<typename T>
requires (detail::UseFormatAs<T>::value)
constexpr auto fmt::to_string (const T &value) -> std::string
template<typename T>
requires (!std::is_integral<T>::value && !detail::UseFormatAs<T>::value)
constexpr auto fmt::to_string (const T &value) -> std::string

Variables

constexpr uint32_t fmt::detail::kInvalidCodePoint = ~uint32_t()
constexpr int fmt::kInlineBufferSize = 500

Detailed Description

Formatting of built-in types: integers, floating point, strings and pointers, with the buffer and presentation-spec machinery behind them.

Interface partition fmt:format.

Typedef Documentation

◆ ConvertFloatResult

template<typename T, bool doublish = numBits<T>() == numBits<double>()>
using fmt::detail::ConvertFloatResult
Initial value:
conditional_t<std::is_same<T, float>::value || doublish, double, T>

◆ IsBuiltin

template<typename T>
using fmt::detail::IsBuiltin
Initial value:
bool_constant<std::is_same<T, int>::value || FMT_BUILTIN_TYPES>

◆ IsInteger

template<typename T>
using fmt::detail::IsInteger
Initial value:
bool_constant<
IsIntegral<T>::value && !std::is_same<T, bool>::value &&
!std::is_same<T, char>::value && !std::is_same<T, wchar_t>::value>
Definition format.cppm:616

◆ IsSigned

template<typename T>
using fmt::detail::IsSigned
Initial value:
std::integral_constant<bool,
std::numeric_limits<T>::is_signed ||
std::is_same<T, NativeInt128>::value>

◆ MemoryBuffer

using fmt::MemoryBuffer = BasicMemoryBuffer<char>
export

A growable char buffer with storage.

◆ ReserveIterator

template<typename OutputIt>
using fmt::detail::ReserveIterator
Initial value:
remove_reference_t<decltype(reserve(std::declval<OutputIt&>(), 0))>

◆ uint32_or_64_or_128_t

template<typename T>
using fmt::detail::uint32_or_64_or_128_t
Initial value:
conditional_t<
numBits<T>() <= 32 && !FMT_REDUCE_INT_INSTANTIATIONS,
uint32_t,
conditional_t<numBits<T>() <= 64, uint64_t, uint128_t>>

◆ uint64_or_128_t

template<typename T>
using fmt::detail::uint64_or_128_t
Initial value:
conditional_t<numBits<T>() <= 64, uint64_t, uint128_t>

Function Documentation

◆ format() [1/2]

template<typename... T>
auto fmt::format ( FormatString< T... > fmt,
T &&... args ) -> std::string
nodiscardexport

Formats args according to specifications in fmt and returns the result as a string.

Example:

#include <fmt/format.hpp>
std::string message = fmt::format("The answer is {}.", 42);

◆ format() [2/2]

template<typename... T>
auto fmt::format ( LocaleRef loc,
FormatString< T... > fmt,
T &&... args ) -> std::string
export

Formats args using the locale loc and returns the result as a string.

Only specifications with the L flag consult the locale; everything else is locale-independent.

Parameters
locthe locale to use.
fmta format string, checked at compile time.
argsthe arguments to format.
Returns
the formatted string.

Example:

auto s = fmt::format(std::locale("en_US.UTF-8"), "{:L}",

1234567);

◆ formatAs()

template<typename Enum>
requires (std::is_enum<Enum>::value)
auto fmt::enums::formatAs ( Enum e) -> underlying_t< Enum >
constexprexportnoexcept

Formats any enumeration as its underlying integer.

Opt in with using namespace fmt::enums; where the enumeration is used, or define a formatAs overload for a specific type instead.

◆ formatSystemError()

auto fmt::formatSystemError ( detail::Buffer< char > & out,
int error_code,
const char * message ) -> void
exportnoexcept

Formats an error message for an error returned by an operating system or a language runtime, for example a file opening error, and writes it to out. The format is the same as the one used by std::system_error(ec, message) where ec is std::error_code(error_code, std::generic_category()). It is implementation-defined but normally looks like:

<message>: <system-message>

where <message> is the passed message and <system-message> is the system message corresponding to the error code. error_code is a system error code as given by errno.

◆ formattedSize()

template<typename... T>
auto fmt::formattedSize ( LocaleRef loc,
FormatString< T... > fmt,
T &&... args ) -> size_t
nodiscardexport

Returns the number of characters format would produce, using loc.

Parameters
locthe locale to use.
fmta format string, checked at compile time.
argsthe arguments to format.
Returns
the length of the output.

◆ groupDigits()

template<typename T>
auto fmt::groupDigits ( T value) -> GroupDigitsView< T >
export

Returns a view that formats an integer value using ',' as a locale-independent thousands separator.

Example:

fmt::print("{}", fmt::groupDigits(12345));
// Output: "12,345"

◆ ptr()

template<typename T>
auto fmt::ptr ( T p) -> const void *
export

Converts p to const void* for pointer formatting.

Example:

auto s = fmt::format("{}", fmt::ptr(p));

◆ reportSystemError()

auto fmt::reportSystemError ( int error_code,
const char * message ) -> void
exportnoexcept

Reports a system error without throwing, for use in destructors.

Parameters
error_codea system error code, as given by errno.
messagethe message to prefix the system message with.

◆ systemError()

template<typename... T>
auto fmt::systemError ( int error_code,
FormatString< T... > fmt,
T &&... args ) -> std::system_error
export

Constructs std::system_error with a message formatted with fmt::format(fmt, args...). error_code is a system error code as given by errno.

Example:

// This throws std::system_error with the description
//   cannot open file 'madeup': No such file or directory
// or similar (system message may vary).
const char* filename = "madeup";
FILE* file = fopen(filename, "r");
if (!file)
  throw fmt::systemError(errno, "cannot open file '{}'",

filename);

◆ to_string() [1/2]

template<size_t SIZE>
auto fmt::to_string ( const BasicMemoryBuffer< char, SIZE > & buf) -> std::string
nodiscardexport

Converts the contents of buf to a std::string.

Parameters
bufthe buffer to copy from.
Returns
the buffer contents as a string.

◆ to_string() [2/2]

template<typename T>
requires (std::is_integral<T>::value)
auto fmt::to_string ( T value) -> std::string
nodiscardconstexprexport

Converts value to std::string using the default format for type T.

Example:

std::string answer = fmt::to_string(42);

◆ underlying()

template<typename Enum>
auto fmt::underlying ( Enum e) -> underlying_t< Enum >
constexprexportnoexcept

Converts e to the underlying type.

Example:

enum class color { red, green, blue };
auto s = fmt::format("{}", fmt::underlying(color::red));  // s ==

"0"

◆ vformat()

auto fmt::vformat ( LocaleRef loc,
StringView fmt,
FormatArgs args ) -> std::string
export

Type-erased form of the locale-aware format.

◆ vformatTo()

template<typename OutputIt>
requires (detail::IsOutputIterator<OutputIt, char>::value)
auto fmt::vformatTo ( OutputIt out,
LocaleRef loc,
StringView fmt,
FormatArgs args ) -> OutputIt
export

Formats args using the locale loc and writes the result to out.

Parameters
outan output iterator to write to.
locthe locale to use.
fmta format string.
argsthe type-erased arguments.
Returns
an iterator past the end of the output.

Variable Documentation

◆ kInlineBufferSize

int fmt::kInlineBufferSize = 500
constexprexport

The default capacity of basic_memory_buffer, in elements.