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

How can I make this custom fmt formatter code cleaner?

I want to write a custom formatter for simple structures inheriting from the existing formatters to access all their options. For example, I've written this for a rectangle: #include template struct rect { T x; T…
user1906
  • 2,310
  • 2
  • 20
  • 37
0
votes
1 answer

-Wstringop-overflow compiler warning in custom fmt::formatter> specialization

I am trying to create a specialization of fmt::formatter for std::bitset class. However I'm getting an ambiguos warning message from GCC when compiling the below program: #include #include #include template…
digito_evo
  • 3,216
  • 2
  • 14
  • 42
0
votes
1 answer

How to use RGB codes with the fmt library?

I just installed the fmt library and I was wondering if it is possible to use RGB codes instead of color names. For example, instead of, #include int main() { std::string cpp = fmt::format(fg(fmt::color::yellow), "C++20"); …
q-l-p
  • 4,304
  • 3
  • 16
  • 36
0
votes
2 answers

How to omit the empty arguments in fmt::format?

Is there a way to omit the empty string literals ("") in the argument list of the fmt::format function? I have the below snippet which gives the desired output: #include #include int main( ) { const std::string…
digito_evo
  • 3,216
  • 2
  • 14
  • 42
0
votes
1 answer

format boost multiprecision cpp_int with fmt

I'm trying to format a boost multiprecision cpp_int using fmt library. Here's the code I tried using boost::multiprecision::cpp_int; int main() { cpp_int v("0x8FFFFFFFFFFFFFFFF"); std::string buffer; …
Vlad Keel
  • 372
  • 2
  • 13
0
votes
1 answer

format string with a variable size vector of arguments using fmt

I'm looking for a way to format a string with a variable-size vector of variables. How to do it? I've already read format string with a variable size vector of arguments (e.g. pass vector of arguments to std::snprintf) and I like the code of this…
Edziju
  • 399
  • 11
0
votes
0 answers

C++: Error occurs when fmt library is included

https://github.com/fmtlib/fmt I'm having trouble using c++ library on ubuntu eclipse. I downloaded the fmt library from github. I followed the steps as described in the documentation section Building the Library. In fmt folder; mkdir build # Create…
Onur94
  • 51
  • 3
0
votes
0 answers

Wide strings with fmtlib

From these github issues, formatting wide strings seem to be supported: https://github.com/fmtlib/fmt/issues/690 https://github.com/fmtlib/fmt/issues/765 But I cant get hello world to compile https://godbolt.org/z/9v6hb3Pd8 gcc's error…
Tom Huntington
  • 2,260
  • 10
  • 20
0
votes
1 answer

How to setup {fmt} library for Unreal Engine project?

I'm trying to setup fmt for UE4 project, but still getting compiler errors. Used toolchain: MSVC\14.16.27023 fmt lib is build from source. I googled this issue and undefined check macro. #undef check #include void test() { auto…
Bard
  • 21
  • 4
0
votes
1 answer

std::format errors "no matching function" and "call to consteval function"

Platform: Win 10 64 bit IDE: CLION 2022.2.4 Toolchain: VS 2022 Community Toolset v17.0 (CMAKE 3.23.2) Build Tool ninja.exe C++ compiler: cl.exe #include #include #include int main() { std::wstring test1 =…
J. Baumann
  • 13
  • 5
0
votes
1 answer

Does vcpkg still work on macOS since new M series laptops?

While using QtCretor I put together the following: #include #include #include using namespace std; int main(int argc, char *argv[]) { cout << "starting..." << endl; std::string s = fmt::format("The…
KcFnMi
  • 5,516
  • 10
  • 62
  • 136
0
votes
0 answers

Conan profile for Windows throwing errors

I am trying to build a small workable C++ project on Windows OS with Conan and CMake. I installed conan using pip install conan I created a profile called conan_common_profile. I did NOT create a CmakeLists.txt . So far my folder only contains two…
0
votes
0 answers

Wrapping function with utility gives constexpr error

I know the title is super confusing, but the following will make it clear. I am using fmt library for formating and it has this precious feature. auto res = fmt::format(FMT_STRING("{}{}"), 6, "Ed"); This is a compile time check on various things…
Eduard Rostomyan
  • 7,050
  • 2
  • 37
  • 76
0
votes
1 answer

Bazel build project with fmtlib. Cpp

I'm trying to build a project on the cpp with a dynamic library that lies in /usr/lib64/libfmt.so. The lib module builds without errors, but for some reason the main fails with an error: INFO: Analyzed target //main:main (1 packages loaded, 7…
Boris
  • 1
  • 1
0
votes
2 answers

What is the best way to define the same fmt::formatter for multiple types?

I am attempting to write a custom formatter for a Vector vector. Depending on build settings, this could be a std::vector, or a __gnu_debug::vector. Both these types present an identical external interface, and I would like to format both…
Chuu
  • 4,301
  • 2
  • 28
  • 54