WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
Print.hpp
Go to the documentation of this file.
1// Copyright (c) Sleipnir contributors
2
3#pragma once
4
5#include <cstdio>
6#include <system_error>
7#include <utility>
8
9#if __has_include(<fmt/base.h>)
10#include <fmt/base.h>
11#else
12#include <fmt/core.h>
13#endif
14
15namespace sleipnir {
16
17/**
18 * Wrapper around fmt::print() that squelches write failure exceptions.
19 */
20template <typename... T>
21inline void print(fmt::format_string<T...> fmt, T&&... args) {
22 try {
23 fmt::print(fmt, std::forward<T>(args)...);
24 } catch (const std::system_error&) {
25 }
26}
27
28/**
29 * Wrapper around fmt::print() that squelches write failure exceptions.
30 */
31template <typename... T>
32inline void print(std::FILE* f, fmt::format_string<T...> fmt, T&&... args) {
33 try {
34 fmt::print(f, fmt, std::forward<T>(args)...);
35 } catch (const std::system_error&) {
36 }
37}
38
39/**
40 * Wrapper around fmt::println() that squelches write failure exceptions.
41 */
42template <typename... T>
43inline void println(fmt::format_string<T...> fmt, T&&... args) {
44 try {
45 fmt::println(fmt, std::forward<T>(args)...);
46 } catch (const std::system_error&) {
47 }
48}
49
50/**
51 * Wrapper around fmt::println() that squelches write failure exceptions.
52 */
53template <typename... T>
54inline void println(std::FILE* f, fmt::format_string<T...> fmt, T&&... args) {
55 try {
56 fmt::println(f, fmt, std::forward<T>(args)...);
57 } catch (const std::system_error&) {
58 }
59}
60
61} // namespace sleipnir
Definition Hessian.hpp:18
void println(fmt::format_string< T... > fmt, T &&... args)
Wrapper around fmt::println() that squelches write failure exceptions.
Definition Print.hpp:43
void print(fmt::format_string< T... > fmt, T &&... args)
Wrapper around fmt::print() that squelches write failure exceptions.
Definition Print.hpp:21