Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
fmt_defs.hpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
10#pragma once
11
20#include <fmt/core.h>
21#include <fmt/format.h>
22#include <fmt/printf.h>
23#include <fmt/ranges.h>
24
25#ifndef DOXYGEN
26template<class T>
27struct fmt::formatter<sycl::vec<T, 2>> {
28
29 template<typename ParseContext>
30 constexpr auto parse(ParseContext &ctx) {
31 return ctx.begin();
32 }
33
34 template<typename FormatContext>
35 auto format(sycl::vec<T, 2> c, FormatContext &ctx) const {
36 return fmt::format_to(ctx.out(), "({},{})", c.x(), c.y());
37 }
38};
39
40template<class T>
41struct fmt::formatter<sycl::vec<T, 3>> {
42
43 template<typename ParseContext>
44 constexpr auto parse(ParseContext &ctx) {
45 return ctx.begin();
46 }
47
48 template<typename FormatContext>
49 auto format(sycl::vec<T, 3> c, FormatContext &ctx) const {
50 return fmt::format_to(ctx.out(), "({},{},{})", c.x(), c.y(), c.z());
51 }
52};
53
54template<class T>
55struct fmt::formatter<sycl::vec<T, 4>> {
56
57 template<typename ParseContext>
58 constexpr auto parse(ParseContext &ctx) {
59 return ctx.begin();
60 }
61
62 template<typename FormatContext>
63 auto format(sycl::vec<T, 4> c, FormatContext &ctx) const {
64 return fmt::format_to(ctx.out(), "({},{},{},{})", c.x(), c.y(), c.z(), c.w());
65 }
66};
67
68template<class T>
69struct fmt::formatter<sycl::vec<T, 8>> {
70
71 template<typename ParseContext>
72 constexpr auto parse(ParseContext &ctx) {
73 return ctx.begin();
74 }
75
76 template<typename FormatContext>
77 auto format(sycl::vec<T, 8> c, FormatContext &ctx) const {
78 return fmt::format_to(
79 ctx.out(),
80 "({},{},{},{},{},{},{},{})",
81 c.s0(),
82 c.s1(),
83 c.s2(),
84 c.s3(),
85 c.s4(),
86 c.s5(),
87 c.s6(),
88 c.s7());
89 }
90};
91
92template<class T>
93struct fmt::formatter<sycl::vec<T, 16>> {
94
95 template<typename ParseContext>
96 constexpr auto parse(ParseContext &ctx) {
97 return ctx.begin();
98 }
99
100 template<typename FormatContext>
101 auto format(sycl::vec<T, 16> c, FormatContext &ctx) const {
102 return fmt::format_to(
103 ctx.out(),
104 "(({},{},{},{}),({},{},{},{}),({},{},{},{}),({},{},{},{}))",
105 c.s0(),
106 c.s1(),
107 c.s2(),
108 c.s3(),
109 c.s4(),
110 c.s5(),
111 c.s6(),
112 c.s7(),
113 c.s8(),
114 c.s9(),
115 c.sA(),
116 c.sB(),
117 c.sC(),
118 c.sD(),
119 c.sE(),
120 c.sF());
121 }
122};
123
124#endif