Skip to content

SiddiqSoft/format-helpers

Repository files navigation

format-helpers

C++20 std::format helpers

CodeQL Build Status

API

Usage

    include "siddiqsoft/formatters.hpp"
    ..
    std::atomic_bool b{false};

    std::cout  << std::format( "b contains {}\n", b);
    std::wcout << std::format(L"b contains {}\n", b);

Output

    false
    false
Type Comment
std::atomic<T>
std::atomic_int
std::atomic_uint
std::atomic_uint64_t
std::atomic_int64_t
std::atomic_bool
Convenience helpers so you don't have to .load() when using std::format.
std::exception Support for both char and wchar_t destinations.
std::runtime_error Support for both char and wchar_t destinations.
nlohmann::json If the library nlohmann.json is present the source json object is serialized and the output is converted to std::wstring as needed.

Dependencies

None. However, if you're using the nlohmann.json library then we will enable the serializers for that library.

  • This library does not use any Windows-specific code. However, use Visual Studio 2019 v16.11.2 or newer as support for <format> is not present for GCC or Clang!
  • On Windows with VisualStudio, use the Nuget package!
  • Make sure you use c++latest as the <format> is no longer in the c++20 option pending ABI resolution.