#include <cstdio>
#include <cstring>
#include <iterator>
#include <string>
#include <type_traits>
Go to the source code of this file.
Namespaces | |
internal | |
Macros | |
#define | FMT_VERSION 60102 |
#define | FMT_HAS_FEATURE(x) 0 |
#define | FMT_HAS_INCLUDE(x) 0 |
#define | FMT_HAS_CPP_ATTRIBUTE(x) 0 |
#define | FMT_GCC_VERSION 0 |
#define | FMT_HAS_GXX_CXX11 0 |
#define | FMT_NVCC 0 |
#define | FMT_MSC_VER 0 |
#define | FMT_USE_CONSTEXPR |
#define | FMT_CONSTEXPR inline |
#define | FMT_CONSTEXPR_DECL |
#define | FMT_OVERRIDE |
#define | FMT_EXCEPTIONS 1 |
#define | FMT_USE_NOEXCEPT 0 |
#define | FMT_DETECTED_NOEXCEPT throw() |
#define | FMT_HAS_CXX11_NOEXCEPT 0 |
#define | FMT_NOEXCEPT FMT_DETECTED_NOEXCEPT |
#define | FMT_NORETURN |
#define | FMT_DEPRECATED /* deprecated */ |
using | FMT_DEPRECATED_ALIAS FMT_DEPRECATED |
#define | FMT_INLINE_NAMESPACE namespace |
#define | FMT_END_NAMESPACE |
#define | FMT_BEGIN_NAMESPACE |
#define | FMT_API |
#define | FMT_EXTERN_TEMPLATE_API |
#define | FMT_EXTERN extern |
#define | FMT_ENABLE_IF(...) enable_if_t<(__VA_ARGS__), int> = 0 |
#define | FMT_ASSERT(condition, message) |
#define | FMT_USE_INT128 0 |
#define | FMT_TYPE_CONSTANT(Type, constant) |
Typedefs | |
template<bool B, class T = void> | |
using | enable_if_t = typename std::enable_if< B, T >::type |
template<bool B, class T , class F > | |
using | conditional_t = typename std::conditional< B, T, F >::type |
template<bool B> | |
using | bool_constant = std::integral_constant< bool, B > |
template<typename T > | |
using | remove_reference_t = typename std::remove_reference< T >::type |
template<typename T > | |
using | remove_const_t = typename std::remove_const< T >::type |
template<typename T > | |
using | remove_cvref_t = typename std::remove_cv< remove_reference_t< T > >::type |
template<typename... Ts> | |
using | void_t = typename internal::void_t_impl< Ts... >::type |
using | string_view = basic_string_view< char > |
using | wstring_view = basic_string_view< wchar_t > |
template<typename S > | |
using | char_t = typename internal::char_t_impl< S >::type |
using | format_parse_context = basic_format_parse_context< char > |
using | wformat_parse_context = basic_format_parse_context< wchar_t > |
using | FMT_DEPRECATED_ALIAS = basic_format_parse_context< Char, ErrorHandler > |
template<typename T , typename Context > | |
using | has_formatter = std::is_constructible< typename Context::template formatter_type< T > > |
template<typename T , typename Context > | |
using | has_fallback_formatter = std::is_constructible< fallback_formatter< T, typename Context::char_type > > |
using | long_type = conditional_t< long_short, int, long long > |
using | ulong_type = conditional_t< long_short, unsigned, unsigned long long > |
template<typename T , typename Context > | |
using | mapped_type_constant = type_constant< decltype(arg_mapper< Context >().map(std::declval< const T & >())), typename Context::char_type > |
template<typename Char > | |
using | buffer_context = basic_format_context< std::back_insert_iterator< internal::buffer< Char > >, Char > |
using | format_context = buffer_context< char > |
using | wformat_context = buffer_context< wchar_t > |
template<bool... Args> | |
using | all_true = std::is_same< bool_pack< Args..., true >, bool_pack< true, Args... > > |
Enumerations | |
enum | char8_t : unsigned char |
enum | type { none_type, named_arg_type, int_type, uint_type, long_long_type, ulong_long_type, int128_type, uint128_type, bool_type, char_type, last_integer_type = char_type, float_type, double_type, long_double_type, last_numeric_type = long_double_type, cstring_type, string_type, pointer_type, custom_type } |
enum | { long_short = sizeof(long) == sizeof(int) } |
enum | { packed_arg_bits = 5 } |
enum | { max_packed_args = 63 / packed_arg_bits } |
enum | : unsigned long long { is_unpacked_bit = 1ULL << 63 } |
Functions | |
FMT_API void | assert_fail (const char *file, int line, const char *message) |
template<typename Int > | |
FMT_CONSTEXPR std::make_unsigned< Int >::type | to_unsigned (Int value) |
template<typename Char , FMT_ENABLE_IF(is_char< Char >::value) > | |
basic_string_view< Char > | to_string_view (const Char *s) |
template<typename Char , typename Traits , typename Alloc > | |
basic_string_view< Char > | to_string_view (const std::basic_string< Char, Traits, Alloc > &s) |
template<typename Char > | |
basic_string_view< Char > | to_string_view (basic_string_view< Char > s) |
template<typename Char , FMT_ENABLE_IF(!std::is_empty< internal::std_string_view< Char >>::value) > | |
basic_string_view< Char > | to_string_view (internal::std_string_view< Char > s) |
template<typename S , FMT_ENABLE_IF(is_compile_string< S >::value) > | |
constexpr basic_string_view< typename S::char_type > | to_string_view (const S &s) |
void | to_string_view (...) |
template<typename Container > | |
Container & | get_container (std::back_insert_iterator< Container > it) |
FMT_TYPE_CONSTANT (const named_arg_base< Char > &, named_arg_type) | |
FMT_TYPE_CONSTANT (int, int_type) | |
FMT_TYPE_CONSTANT (unsigned, uint_type) | |
FMT_TYPE_CONSTANT (long long, long_long_type) | |
FMT_TYPE_CONSTANT (unsigned long long, ulong_long_type) | |
FMT_TYPE_CONSTANT (int128_t, int128_type) | |
FMT_TYPE_CONSTANT (uint128_t, uint128_type) | |
FMT_TYPE_CONSTANT (bool, bool_type) | |
FMT_TYPE_CONSTANT (Char, char_type) | |
FMT_TYPE_CONSTANT (float, float_type) | |
FMT_TYPE_CONSTANT (double, double_type) | |
FMT_TYPE_CONSTANT (long double, long_double_type) | |
FMT_TYPE_CONSTANT (const Char *, cstring_type) | |
FMT_TYPE_CONSTANT (basic_string_view< Char >, string_type) | |
FMT_TYPE_CONSTANT (const void *, pointer_type) | |
FMT_CONSTEXPR bool | is_integral_type (type t) |
FMT_CONSTEXPR bool | is_arithmetic_type (type t) |
template<typename Context , typename T > | |
FMT_CONSTEXPR basic_format_arg< Context > | make_arg (const T &value) |
template<typename Visitor , typename Context > | |
FMT_CONSTEXPR auto | visit_format_arg (Visitor &&vis, const basic_format_arg< Context > &arg) -> decltype(vis(0)) |
template<typename > | |
constexpr unsigned long long | encode_types () |
template<typename Context , typename Arg , typename... Args> | |
constexpr unsigned long long | encode_types () |
template<bool IS_PACKED, typename Context , typename T , FMT_ENABLE_IF(IS_PACKED) > | |
value< Context > | make_arg (const T &val) |
template<bool IS_PACKED, typename Context , typename T , FMT_ENABLE_IF(!IS_PACKED) > | |
basic_format_arg< Context > | make_arg (const T &value) |
template<typename Context = format_context, typename... Args> | |
format_arg_store< Context, Args... > | make_format_args (const Args &... args) |
template<typename... , typename S , FMT_ENABLE_IF(!is_compile_string< S >::value) > | |
void | check_format_string (const S &) |
template<typename... , typename S , FMT_ENABLE_IF(is_compile_string< S >::value) > | |
void | check_format_string (S) |
template<typename... Args, typename S , typename Char = char_t<S>> | |
format_arg_store< buffer_context< Char >, remove_reference_t< Args >... > | make_args_checked (const S &format_str, const remove_reference_t< Args > &... args) |
template<typename Char > | |
std::basic_string< Char > | vformat (basic_string_view< Char > format_str, basic_format_args< buffer_context< Char >> args) |
template<typename Char > | |
buffer_context< Char >::iterator | vformat_to (buffer< Char > &buf, basic_string_view< Char > format_str, basic_format_args< buffer_context< Char >> args) |
template<typename S , typename T , typename Char = char_t<S>> | |
internal::named_arg< T, Char > | arg (const S &name, const T &arg) |
template<typename S , typename T , typename Char > | |
void | arg (S, internal::named_arg< T, Char >)=delete |
template<typename OutputIt , typename S , typename Char = char_t<S>, FMT_ENABLE_IF( internal::is_contiguous_back_insert_iterator< OutputIt >::value) > | |
OutputIt | vformat_to (OutputIt out, const S &format_str, basic_format_args< buffer_context< Char >> args) |
template<typename Container , typename S , typename... Args, FMT_ENABLE_IF( is_contiguous< Container >::value &&internal::is_string< S >::value) > | |
std::back_insert_iterator< Container > | format_to (std::back_insert_iterator< Container > out, const S &format_str, Args &&... args) |
template<typename S , typename Char = char_t<S>> | |
std::basic_string< Char > | vformat (const S &format_str, basic_format_args< buffer_context< Char >> args) |
template<typename S , typename... Args, typename Char = char_t<S>> | |
std::basic_string< Char > | format (const S &format_str, Args &&... args) |
FMT_API void | vprint (std::FILE *f, string_view format_str, format_args args) |
FMT_API void | vprint (string_view format_str, format_args args) |
template<typename S , typename... Args, FMT_ENABLE_IF(internal::is_string< S >::value) > | |
void | print (std::FILE *f, const S &format_str, Args &&... args) |
template<typename S , typename... Args, FMT_ENABLE_IF(internal::is_string< S >::value) > | |
void | print (const S &format_str, Args &&... args) |
#define FMT_API |
Definition at line 177 of file core.h.
Referenced by buffered_file::buffered_file(), internal::decimal_point_impl(), system_error::error_code(), format(), buffered_file::get(), internal::grouping< wchar_t >(), buffered_file::operator=(), buffered_file::print(), and internal::thousands_sep().
#define FMT_ASSERT | ( | condition, | |
message | |||
) |
Definition at line 233 of file core.h.
Referenced by bigint::divmod_assign(), internal::format_decimal(), internal::format_float(), text_style::get_background(), text_style::get_emphasis(), text_style::get_foreground(), internal::get_round_direction(), internal::grisu_gen_digits(), internal::is_arithmetic_type(), internal::is_integral_type(), fixed_handler::on_digit(), arg_formatter_base< Range >::operator()(), bigint::operator*=(), basic_memory_buffer< Char >::operator=(), formatter< T, Char, enable_if_t< internal::type_constant< T, Char >::value !=internal::custom_type > >::parse(), internal::parse_align(), internal::parse_arg_id(), internal::parse_nonnegative_int(), internal::parse_width(), internal::safe_strerror(), internal::snprintf_float(), bigint::subtract_aligned(), internal::to_nonnegative_int(), internal::to_unsigned(), visit_format_arg(), and internal::write_exponent().
#define FMT_BEGIN_NAMESPACE |
Definition at line 163 of file core.h.
Referenced by strerror_s().
#define FMT_CONSTEXPR inline |
Definition at line 75 of file core.h.
Referenced by internal::compile_to_parts(), value< basic_format_context >::format_custom_arg(), internal::format_str_quoted(), internal::is_negative(), safe_duration_cast::lossless_integral_conversion(), internal::parse_format_string(), safe_duration_cast::safe_float_conversion(), and vprint().
#define FMT_CONSTEXPR_DECL |
Definition at line 76 of file core.h.
Referenced by internal::check_format_string(), compiled_format_base< S, enable_if_t< is_compile_string< S >::value > >::compiled_format_base(), compiled_format_base< S, enable_if_t< is_compile_string< S >::value > >::parts(), text_style::text_style(), and vprint().
typedef internal::basic_writer< buffer_range< wchar_t > > FMT_DEPRECATED_ALIAS FMT_DEPRECATED |
#define FMT_ENABLE_IF | ( | ... | ) | enable_if_t<(__VA_ARGS__), int> = 0 |
Definition at line 220 of file core.h.
Referenced by basic_string_view< char >::basic_string_view(), internal::check_format_string(), compile(), compiled_format< S, Args >::compiled_format(), internal::copy_str(), internal::fmt_safe_duration_cast(), internal::for_each(), format(), internal::format_str_quoted(), format_to(), internal::get_milliseconds(), safe_duration_cast::lossless_integral_conversion(), internal::make_arg(), make_format_to_n_args(), arg_mapper< Context >::map(), named_arg< T, Char >::named_arg(), print(), safe_duration_cast::safe_duration_cast(), safe_duration_cast::safe_float_conversion(), to_string_view(), vformat_to(), vformat_to_n(), vprint(), and vprintf().
#define FMT_END_NAMESPACE |
Definition at line 158 of file core.h.
Referenced by format(), formatter< std::chrono::duration< Rep, Period >, Char >::format(), format_to(), formatted_size(), fprintf(), join(), buffered_file::print(), print(), and vprint().
#define FMT_NOEXCEPT FMT_DETECTED_NOEXCEPT |
Definition at line 114 of file core.h.
Referenced by buffered_file::buffered_file(), internal::decimal_point_impl(), system_error::error_code(), formatter< internal::bigint >::format(), format_error::format_error(), buffered_file::print(), report_system_error(), system_error::system_error(), and text_style::text_style().
#define FMT_OVERRIDE |
Definition at line 84 of file core.h.
Referenced by basic_memory_buffer< Char >::deallocate(), format_error::format_error(), and system_error::system_error().
#define FMT_TYPE_CONSTANT | ( | Type, | |
constant | |||
) |
#define FMT_USE_CONSTEXPR |
using bool_constant = std::integral_constant<bool, B> |
using buffer_context = basic_format_context<std::back_insert_iterator<internal::buffer<Char> >, Char> |
using char_t = typename internal::char_t_impl<S>::type |
using conditional_t = typename std::conditional<B, T, F>::type |
using enable_if_t = typename std::enable_if<B, T>::type |
using FMT_DEPRECATED_ALIAS = basic_format_parse_context<wchar_t> |
using format_context = buffer_context<char> |
using format_parse_context = basic_format_parse_context<char> |
using has_formatter = std::is_constructible<typename Context::template formatter_type<T> > |
using remove_const_t = typename std::remove_const<T>::type |
using remove_cvref_t = typename std::remove_cv<remove_reference_t<T> >::type |
using remove_reference_t = typename std::remove_reference<T>::type |
using string_view = basic_string_view<char> |
using void_t = typename internal::void_t_impl<Ts...>::type |
using wformat_context = buffer_context<wchar_t> |
using wformat_parse_context = basic_format_parse_context<wchar_t> |
using wstring_view = basic_string_view<wchar_t> |
internal::named_arg<T, Char> arg | ( | const S & | name, |
const T & | arg | ||
) |
Returns a named argument to be used in a formatting function.
The named argument holds a reference and does not extend the lifetime of its arguments. Consequently, a dangling reference can accidentally be created. The user should take care to only pass this function temporaries when the named argument is itself a temporary, as per the following example.
Example**::
fmt::print("Elapsed time: {s:.2f} seconds", fmt::arg("s", 1.23));
Definition at line 1422 of file core.h.
Referenced by basic_format_context< OutputIt, Char >::arg(), compiled_format< S, Args >::compiled_format(), named_arg_base< char_type >::deserialize(), basic_format_args< basic_format_context >::do_get(), basic_printf_context< OutputIt, Char >::format(), basic_format_args< basic_format_context >::get(), internal::get_arg(), format_handler< ArgFormatter, Char, Context >::get_arg(), internal::make_arg(), arg_mapper< Context >::map(), format_handler< ArgFormatter, Char, Context >::on_arg_id(), format_handler< ArgFormatter, Char, Context >::on_format_specs(), format_handler< ArgFormatter, Char, Context >::on_replacement_field(), internal::cf::vformat_to(), and visit_format_arg().
|
delete |
std::basic_string<Char> format | ( | const S & | format_str, |
Args &&... | args | ||
) |
Formats arguments and returns the result as a string.
Example**::
#include <fmt/core.h> std::string message = fmt::format("The answer is {}", 42);
Definition at line 1475 of file core.h.
References FMT_API, FMT_ENABLE_IF, internal::make_args_checked(), to_string_view(), internal::vformat(), and vprint().
std::back_insert_iterator<Container> format_to | ( | std::back_insert_iterator< Container > | out, |
const S & | format_str, | ||
Args &&... | args | ||
) |
Definition at line 1448 of file core.h.
References internal::make_args_checked(), to_string_view(), and vformat_to().
format_arg_store<Context, Args...> make_format_args | ( | const Args &... | args | ) |
Constructs an ~fmtformat_arg_store
object that contains references to arguments and can be implicitly converted to ~fmtformat_args
. Context
can be omitted in which case it defaults to ~fmt::context
. See ~fmtarg
for lifetime considerations.
Definition at line 1225 of file core.h.
Referenced by system_error::error_code(), buffered_file::print(), and system_error::system_error().
void print | ( | std::FILE * | f, |
const S & | format_str, | ||
Args &&... | args | ||
) |
Prints formatted data to the file f. For wide format strings, f* should be in wide-oriented mode set via fwide(f, 1)
or _setmode(_fileno(f), _O_U8TEXT)
on Windows.
Example**::
fmt::print(stderr, "Don't {}!", "panic");
Definition at line 1497 of file core.h.
References FMT_ENABLE_IF, to_string_view(), and vprint().
void print | ( | const S & | format_str, |
Args &&... | args | ||
) |
Prints formatted data to stdout
.
Example**::
fmt::print("Elapsed time: {0:.2f} seconds", 1.23);
Definition at line 1513 of file core.h.
References FMT_END_NAMESPACE, to_string_view(), and vprint().
basic_string_view<Char> to_string_view | ( | const Char * | s | ) |
Returns a string view of s
. In order to add custom string type support to {fmt} provide an overload of to_string_view
for it in the same namespace as the type for the argument-dependent lookup to work.
Example**::
namespace my_ns { inline string_view to_string_view(const my_string& s) { return {s.data(), s.length()}; } } std::string message = fmt::format(my_string("The answer is {}"), 42);
Definition at line 397 of file core.h.
Referenced by format(), format_to(), arg_mapper< Context >::map(), print(), to_string_view(), vformat(), vformat_to(), and vprint().
basic_string_view<Char> to_string_view | ( | const std::basic_string< Char, Traits, Alloc > & | s | ) |
basic_string_view<Char> to_string_view | ( | basic_string_view< Char > | s | ) |
Definition at line 408 of file core.h.
References FMT_ENABLE_IF.
basic_string_view<Char> to_string_view | ( | internal::std_string_view< Char > | s | ) |
constexpr basic_string_view<typename S::char_type> to_string_view | ( | const S & | s | ) |
Definition at line 427 of file core.h.
References to_string_view().
std::basic_string<Char> vformat | ( | const S & | format_str, |
basic_format_args< buffer_context< Char >> | args | ||
) |
Definition at line 1457 of file core.h.
References to_string_view(), and internal::vformat().
Referenced by internal::make_args_checked().
OutputIt vformat_to | ( | OutputIt | out, |
const S & | format_str, | ||
basic_format_args< buffer_context< Char >> | args | ||
) |
Formats a string and writes the output to out
.
Definition at line 1437 of file core.h.
References FMT_ENABLE_IF, internal::get_container(), to_string_view(), and internal::vformat_to().
Referenced by format_to(), and internal::make_args_checked().
FMT_CONSTEXPR auto visit_format_arg | ( | Visitor && | vis, |
const basic_format_arg< Context > & | arg | ||
) | -> decltype(vis(0)) |
Visits an argument dispatching to the appropriate visit method based on the argument type. For example, if the argument type is double
then vis(value)
will be called with the value of type double
.
Definition at line 1004 of file core.h.
References arg(), internal::bool_type, internal::char_type, internal::cstring_type, internal::custom_type, internal::double_type, internal::float_type, FMT_ASSERT, internal::int128_type, internal::int_type, internal::long_double_type, internal::long_long_type, internal::named_arg_type, internal::none_type, internal::pointer_type, internal::string_type, internal::uint128_type, internal::uint_type, and internal::ulong_long_type.
Referenced by internal::convert_arg(), basic_printf_context< OutputIt, Char >::format(), formatter< T, Char, enable_if_t< internal::type_constant< T, Char >::value !=internal::custom_type > >::format(), dynamic_formatter< Char >::format(), internal::format_arg(), internal::get_dynamic_spec(), format_handler< ArgFormatter, Char, Context >::on_format_specs(), format_handler< ArgFormatter, Char, Context >::on_replacement_field(), basic_printf_context< OutputIt, Char >::parse_header(), and internal::cf::vformat_to().
FMT_API void vprint | ( | std::FILE * | f, |
string_view | format_str, | ||
format_args | args | ||
) |
Definition at line 1379 of file format-inl.h.
References buffer< T >::data(), internal::fwrite_fully(), buffer< T >::size(), and internal::vformat_to().
FMT_API void vprint | ( | string_view | format_str, |
format_args | args | ||
) |
Definition at line 1386 of file format-inl.h.
References FMT_END_NAMESPACE, and vprint().