WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
print.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <cstdio>
8#include <system_error>
9#include <utility>
10
11#if __has_include(<fmt/base.h>)
12#include <fmt/base.h>
13#else
14#include <fmt/core.h>
15#endif
16
17namespace wpi {
18
19/**
20 * Wrapper around fmt::print() that squelches write failure exceptions.
21 */
22template <typename... T>
23inline void print(fmt::format_string<T...> fmt, T&&... args) {
24 try {
25 fmt::print(fmt, std::forward<T>(args)...);
26 } catch (const std::system_error&) {
27 }
28}
29
30/**
31 * Wrapper around fmt::print() that squelches write failure exceptions.
32 */
33template <typename... T>
34inline void print(std::FILE* f, fmt::format_string<T...> fmt, T&&... args) {
35 try {
36 fmt::print(f, fmt, std::forward<T>(args)...);
37 } catch (const std::system_error&) {
38 }
39}
40
41/**
42 * Wrapper around fmt::println() that squelches write failure exceptions.
43 */
44template <typename... T>
45inline void println(fmt::format_string<T...> fmt, T&&... args) {
46 try {
47 fmt::println(fmt, std::forward<T>(args)...);
48 } catch (const std::system_error&) {
49 }
50}
51
52/**
53 * Wrapper around fmt::println() that squelches write failure exceptions.
54 */
55template <typename... T>
56inline void println(std::FILE* f, fmt::format_string<T...> fmt, T&&... args) {
57 try {
58 fmt::println(f, fmt, std::forward<T>(args)...);
59 } catch (const std::system_error&) {
60 }
61}
62
63} // namespace wpi
Foonathan namespace.
Definition ntcore_cpp.h:26
void print(wpi::raw_ostream &os, const S &format_str, Args &&... args)
Prints formatted data to the stream os.
Definition raw_ostream.h:25
void println(fmt::format_string< T... > fmt, T &&... args)
Wrapper around fmt::println() that squelches write failure exceptions.
Definition print.h:45