cpp-stat-bench 0.24.0
Benchmark library with statistics for C++.
Loading...
Searching...
No Matches
custom_output_name.h
Go to the documentation of this file.
1/*
2 * Copyright 2024 MusicScience37 (Kenta Kabashima)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
20#pragma once
21
22#include <ostream>
23#include <string>
24#include <utility>
25
26#include <fmt/base.h>
27
29
30namespace stat_bench {
31
36public:
42 explicit CustomOutputName(util::Utf8String str) noexcept;
43
49 explicit CustomOutputName(std::string str)
50 : CustomOutputName(util::Utf8String(std::move(str))) {}
51
57 [[nodiscard]] auto str() const noexcept -> const util::Utf8String&;
58
59private:
61 util::Utf8String str_;
62};
63
72[[nodiscard]] inline auto operator==(
73 const CustomOutputName& lhs, const CustomOutputName& rhs) noexcept -> bool {
74 return lhs.str() == rhs.str();
75}
76
85[[nodiscard]] inline auto operator!=(
86 const CustomOutputName& lhs, const CustomOutputName& rhs) noexcept -> bool {
87 return !(lhs == rhs);
88}
89
90} // namespace stat_bench
91
92namespace fmt {
93
98template <>
99struct formatter<stat_bench::CustomOutputName>
100 : public formatter<stat_bench::util::Utf8String> {
109 fmt::format_context& context) const -> fmt::format_context::iterator {
110 return formatter<stat_bench::util::Utf8String>::format(
111 val.str(), context);
112 }
113};
114
115} // namespace fmt
116
117namespace stat_bench {
118
126inline auto operator<<(std::ostream& stream, const CustomOutputName& val)
127 -> std::ostream& {
128 return stream << val.str();
129}
130
131} // namespace stat_bench
Class of names of custom outputs.
CustomOutputName(std::string str)
Constructor.
auto str() const noexcept -> const util::Utf8String &
Get the string of the name.
CustomOutputName(util::Utf8String str) noexcept
Constructor.
Class of UTF-8 encoded string.
Definition utf8_string.h:35
Namespace of utility functions and classes.
Namespace of stat_bench source codes.
auto operator!=(const BenchmarkCaseName &lhs, const BenchmarkCaseName &rhs) noexcept -> bool
Compare two BenchmarkCaseName objects.
auto operator<<(std::ostream &stream, const BenchmarkCaseName &val) -> std::ostream &
Format to a stream.
STL namespace.
auto format(const stat_bench::CustomOutputName &val, fmt::format_context &context) const -> fmt::format_context::iterator
Format.
Definition of Utf8String class.