Questions tagged [fmt]

The {fmt} formatting library and the C++ text formatting and output facility (C++20 `std::format` and C++23 `std::print`).

{fmt} is an open source formatting library for . It is similar in functionality to and sprintf. The formatting facility defined in the <format> header is based on it and provides a subset of {fmt}'s functionality.

259 questions
0
votes
2 answers

Alternative to `#define` macro for function alias in C++

fmtlib has a function like: template > inline std::basic_string format(const S& format_str, Args&&... args) { return internal::vformat( to_string_view(format_str), …
hmmmmmm
  • 321
  • 3
  • 10
0
votes
1 answer

Why C++20 format has no strong typedef for format string?

C++20 introduces the following format function (locale and wstring_view versions ignored since they do not affect the question): template std::string format(std::string_view fmt, const Args&... args); There is nothing wrong with…
NoSenseEtAl
  • 28,205
  • 28
  • 128
  • 277
0
votes
1 answer

does the stack space for temporary objects get reused?

I just came across a something from the fmt library in the format_int class. It has a char buffer member such that when you invoke the class stack space is allocated on the stack in the calling method. You can return a char * from format_int and it…
Medran
  • 433
  • 3
  • 10
0
votes
2 answers

Formatting for windows structures

Having some trouble using fmt lib to create a formatter to print some Windows structures in my code. I've prepared a basic example below. The purpose is to be able to print a large structure out in a pre-structured manner, and only print what I want…
gandolf
  • 3,384
  • 4
  • 21
  • 20
0
votes
1 answer

spdlog header-only with external fmt. spdlog error: 'internal': is not a member of 'fmt'

I am using header-only spdlog as cmake's external project. find_program(GIT_EXECUTABLE git) ExternalProject_Add( spdlog PREFIX ${CMAKE_BINARY_DIR}/vendor/spdlog GIT_REPOSITORY "https://github.com/gabime/spdlog.git" GIT_TAG "v1.6.1" …
Chase Choi
  • 3
  • 1
  • 3
0
votes
2 answers

{fmt} library: How to use RegEx to add compile time string checking?

I am using the {fmt} library. Unfortunately, my program crashed after a few days, as I had an invalid format string. Easily fixed - but what if there are more? It is possible to do compile time checking of string formats, which would have caught…
Contango
  • 76,540
  • 58
  • 260
  • 305
0
votes
1 answer

Is it possible to compile fmt in vs2010

I know Visual studio 2010 is outdated and should not be used. I am just curious if it is possible to compile libfmt.a in vs2010?
psingh
  • 47
  • 1
  • 4
0
votes
0 answers

Can't compile fmt/format.h with g++9.2.1

I am trying to compile sample code from Packt's video series on C++20. It uses , which I installed thus: sudo apt install libfmt-dev. (I'd be happy to just go with C++20's version, but I don't think g++ has it yet.) I'm on Ubuntu 9.10;…
Topological Sort
  • 2,733
  • 2
  • 27
  • 54
0
votes
1 answer

Can be made the fmt library that drake brings private?

My workspace is a ros2-like workspace in which drake has been wrapped into a CMake package. drake is pulling in a specific version of the fmt library which I am able to consume it. But the thing is I need to use another version of fmt that I have…
franco.c
  • 3
  • 2
0
votes
0 answers

Linker errors using FMT for string interpolation in C++

I am trying to use FTM for string interpolation in C++ but it is giving me some linker errors when I try to compile. I have written the following class: #include #include "include/fmt/format.h" class A { public: std::string…
SomeDutchGuy
  • 2,249
  • 4
  • 16
  • 42
-1
votes
1 answer

Which is more efficient, fmt::format or fmt::format_to

This is about the well-known https://fmt.dev/latest/index.html. On the one hand, fmt::format("Mom {} and Dad {}", "Alice", "Bob") is expressive, and on the other hand, fmt::format_to also exists, e.g. auto out =…
Ilonpilaaja
  • 1,169
  • 2
  • 15
  • 26
-1
votes
1 answer

How to disable printing of "-nan" from fmt

I am working on converting some software to using the fmt library, which was previously using a combination of double-conversion, iostream, and boost::format. The majority of numeric values being output are double precision floating point, and we…
peepsalot
  • 422
  • 4
  • 7
-1
votes
1 answer

Generating simple format string at compile time

I'm trying to generate a simple format string for fmt at compile time, but I can't quite figure out the string concatenation. I'm limited to c++ 14. What I'd like is to be able to generate a format string for N items, so it could be used as…
Rob W.
  • 362
  • 5
  • 18
-1
votes
1 answer

What can i implement fmt lib

i try to insert fmt library to my project, but i don't really know what miss. if i complile it's everything ok, but when i want to use fmt::format function, i get…
-1
votes
3 answers

C++ fmtlib : How to convert a double to existing wchar_t buffer?

I'm considering transitioning from snprintf and its ilk to fmtlib. Imagine this fictional code: class CFoo { size_t m_szLen{0}; wchar_t m_pwcDst[123]{}; ... public: void Bar(double dValue, uint8 u8TotDecimals) { m_szLen +=…
Sander Bouwhuis
  • 647
  • 7
  • 8
1 2 3
17
18