Scippy

SoPlex

Sequential object-oriented simPlex

core.h File Reference
#include <cstdio>
#include <cstring>
#include <iterator>
#include <string>
#include <type_traits>

Go to the source code of this file.

Classes

struct  monostate
 
struct  void_t_impl< Ts >
 
struct  std_string_view< T >
 
struct  int128_t
 
struct  uint128_t
 
class  basic_string_view< Char >
 
struct  is_char< T >
 
struct  is_char< char >
 
struct  is_char< wchar_t >
 
struct  is_char< char8_t >
 
struct  is_char< char16_t >
 
struct  is_char< char32_t >
 
struct  compile_string
 
struct  is_compile_string< S >
 
struct  is_string< S >
 
struct  char_t_impl< S, typename >
 
struct  char_t_impl< S, enable_if_t< is_string< S >::value > >
 
struct  error_handler
 
class  basic_format_parse_context< Char, ErrorHandler >
 
class  basic_format_arg< Context >
 
class  basic_format_args< Context >
 
struct  formatter< T, Char, Enable >
 
struct  convert_to_int< T, Char, Enable >
 
class  buffer< T >
 
class  container_buffer< Container >
 
struct  fallback_formatter< T, Char, Enable >
 
struct  named_arg_base< Char >
 
struct  named_arg< T, Char >
 
struct  type_constant< T, Char >
 
struct  string_value< Char >
 
struct  custom_value< Context >
 
class  value< Context >
 
struct  arg_mapper< Context >
 
class  arg_map< Context >
 
class  basic_format_arg< Context >
 
class  basic_format_arg< Context >::handle
 
class  arg_map< Context >
 
struct  arg_map< Context >::entry
 
class  locale_ref
 
class  basic_format_context< OutputIt, Char >
 
class  format_arg_store< Context, Args >
 
class  basic_format_args< Context >
 
struct  format_args
 
struct  wformat_args
 
struct  is_contiguous< Container >
 
struct  is_contiguous< std::basic_string< Char > >
 
struct  is_contiguous< internal::buffer< Char > >
 
struct  is_contiguous_back_insert_iterator< OutputIt >
 
struct  is_contiguous_back_insert_iterator< std::back_insert_iterator< Container > >
 
struct  named_arg_base< Char >
 
struct  named_arg< T, Char >
 
struct  view
 
struct  bool_pack<... >
 

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)
 

Macro Definition Documentation

◆ FMT_API

◆ FMT_ASSERT

◆ FMT_BEGIN_NAMESPACE

#define FMT_BEGIN_NAMESPACE
Value:
namespace fmt { \
FMT_INLINE_NAMESPACE v6 {

Definition at line 163 of file core.h.

Referenced by strerror_s().

◆ FMT_CONSTEXPR

◆ FMT_CONSTEXPR_DECL

◆ FMT_DEPRECATED

#define FMT_DEPRECATED   /* deprecated */

Definition at line 137 of file core.h.

◆ FMT_DEPRECATED_ALIAS

Definition at line 146 of file core.h.

◆ FMT_DETECTED_NOEXCEPT

#define FMT_DETECTED_NOEXCEPT   throw()

Definition at line 108 of file core.h.

◆ FMT_ENABLE_IF

◆ FMT_END_NAMESPACE

#define FMT_END_NAMESPACE

◆ FMT_EXCEPTIONS

#define FMT_EXCEPTIONS   1

Definition at line 94 of file core.h.

◆ FMT_EXTERN

#define FMT_EXTERN   extern

Definition at line 184 of file core.h.

◆ FMT_EXTERN_TEMPLATE_API

#define FMT_EXTERN_TEMPLATE_API

Definition at line 180 of file core.h.

◆ FMT_GCC_VERSION

#define FMT_GCC_VERSION   0

Definition at line 42 of file core.h.

◆ FMT_HAS_CPP_ATTRIBUTE

#define FMT_HAS_CPP_ATTRIBUTE (   x)    0

Definition at line 36 of file core.h.

◆ FMT_HAS_CXX11_NOEXCEPT

#define FMT_HAS_CXX11_NOEXCEPT   0

Definition at line 109 of file core.h.

◆ FMT_HAS_FEATURE

#define FMT_HAS_FEATURE (   x)    0

Definition at line 23 of file core.h.

◆ FMT_HAS_GXX_CXX11

#define FMT_HAS_GXX_CXX11   0

Definition at line 48 of file core.h.

◆ FMT_HAS_INCLUDE

#define FMT_HAS_INCLUDE (   x)    0

Definition at line 30 of file core.h.

◆ FMT_INLINE_NAMESPACE

#define FMT_INLINE_NAMESPACE   namespace

Definition at line 157 of file core.h.

◆ FMT_MSC_VER

#define FMT_MSC_VER   0

Definition at line 60 of file core.h.

◆ FMT_NOEXCEPT

◆ FMT_NORETURN

#define FMT_NORETURN

Definition at line 124 of file core.h.

◆ FMT_NVCC

#define FMT_NVCC   0

Definition at line 54 of file core.h.

◆ FMT_OVERRIDE

#define FMT_OVERRIDE

◆ FMT_TYPE_CONSTANT

#define FMT_TYPE_CONSTANT (   Type,
  constant 
)
Value:
template <typename Char> \
struct type_constant<Type, Char> : std::integral_constant<type, constant> {}

Definition at line 715 of file core.h.

◆ FMT_USE_CONSTEXPR

#define FMT_USE_CONSTEXPR
Value:
(FMT_HAS_FEATURE(cxx_relaxed_constexpr) || FMT_MSC_VER >= 1910 || \
(FMT_GCC_VERSION >= 600 && __cplusplus >= 201402L)) && \
#define FMT_NVCC
Definition: core.h:54
#define FMT_MSC_VER
Definition: core.h:60
#define FMT_GCC_VERSION
Definition: core.h:42
#define FMT_HAS_FEATURE(x)
Definition: core.h:23

Definition at line 66 of file core.h.

◆ FMT_USE_INT128

#define FMT_USE_INT128   0

Definition at line 256 of file core.h.

◆ FMT_USE_NOEXCEPT

#define FMT_USE_NOEXCEPT   0

Definition at line 100 of file core.h.

◆ FMT_VERSION

#define FMT_VERSION   60102

Definition at line 18 of file core.h.

Typedef Documentation

◆ bool_constant

using bool_constant = std::integral_constant<bool, B>

Definition at line 207 of file core.h.

◆ buffer_context

using buffer_context = basic_format_context<std::back_insert_iterator<internal::buffer<Char> >, Char>

Definition at line 1183 of file core.h.

◆ char_t

using char_t = typename internal::char_t_impl<S>::type

String's character type.

Definition at line 458 of file core.h.

◆ conditional_t

using conditional_t = typename std::conditional<B, T, F>::type

Definition at line 206 of file core.h.

◆ enable_if_t

using enable_if_t = typename std::enable_if<B, T>::type

Definition at line 204 of file core.h.

◆ FMT_DEPRECATED_ALIAS

Definition at line 543 of file core.h.

◆ format_context

Definition at line 1184 of file core.h.

◆ format_parse_context

Definition at line 538 of file core.h.

◆ has_formatter

using has_formatter = std::is_constructible<typename Context::template formatter_type<T> >

Definition at line 566 of file core.h.

◆ remove_const_t

using remove_const_t = typename std::remove_const<T>::type

Definition at line 211 of file core.h.

◆ remove_cvref_t

using remove_cvref_t = typename std::remove_cv<remove_reference_t<T> >::type

Definition at line 213 of file core.h.

◆ remove_reference_t

using remove_reference_t = typename std::remove_reference<T>::type

Definition at line 209 of file core.h.

◆ string_view

Definition at line 364 of file core.h.

◆ void_t

using void_t = typename internal::void_t_impl<Ts...>::type

Definition at line 272 of file core.h.

◆ wformat_context

using wformat_context = buffer_context<wchar_t>

Definition at line 1185 of file core.h.

◆ wformat_parse_context

Definition at line 539 of file core.h.

◆ wstring_view

using wstring_view = basic_string_view<wchar_t>

Definition at line 365 of file core.h.

Enumeration Type Documentation

◆ char8_t

enum char8_t : unsigned char

Definition at line 369 of file core.h.

Function Documentation

◆ arg() [1/2]

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().

◆ arg() [2/2]

void arg ( ,
internal::named_arg< T, Char >   
)
delete

◆ format()

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().

◆ format_to()

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().

◆ make_format_args()

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().

◆ print() [1/2]

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().

◆ print() [2/2]

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().

◆ to_string_view() [1/5]

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().

◆ to_string_view() [2/5]

basic_string_view<Char> to_string_view ( const std::basic_string< Char, Traits, Alloc > &  s)

Definition at line 402 of file core.h.

◆ to_string_view() [3/5]

basic_string_view<Char> to_string_view ( basic_string_view< Char >  s)

Definition at line 408 of file core.h.

References FMT_ENABLE_IF.

◆ to_string_view() [4/5]

basic_string_view<Char> to_string_view ( internal::std_string_view< Char >  s)

Definition at line 414 of file core.h.

◆ to_string_view() [5/5]

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().

◆ vformat()

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().

◆ vformat_to()

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().

◆ visit_format_arg()

◆ vprint() [1/2]

FMT_API void vprint ( std::FILE *  f,
string_view  format_str,
format_args  args 
)

◆ vprint() [2/2]

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().