Skip to content

Commit bff768c

Browse files
authored
c++20 standard (#120)
1 parent f77f67b commit bff768c

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.23)
22

33
project(spectator-cpp)
44

5-
set(CMAKE_CXX_STANDARD 17)
5+
set(CMAKE_CXX_STANDARD 20)
66
set(CMAKE_CXX_STANDARD_REQUIRED True)
77
set(CMAKE_CXX_EXTENSIONS OFF)
88
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

spectator/id.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ class Tags {
7474
[[nodiscard]] table_t::const_iterator end() const { return entries_.end(); }
7575
};
7676

77-
inline std::ostream& operator<<(std::ostream& os, const Tags& tags) {
78-
os << fmt::format("{}", tags);
79-
return os;
80-
}
81-
8277
class Id {
8378
public:
8479
Id(absl::string_view name, Tags tags) noexcept
@@ -131,11 +126,6 @@ class Id {
131126
}
132127
}
133128

134-
friend std::ostream& operator<<(std::ostream& os, const Id& id) {
135-
os << fmt::format("{}", id);
136-
return os;
137-
}
138-
139129
friend struct std::hash<Id>;
140130

141131
friend struct std::hash<std::shared_ptr<Id>>;
@@ -186,7 +176,7 @@ struct equal_to<shared_ptr<spectator::Id>> {
186176

187177
} // namespace std
188178

189-
template <> struct fmt::formatter<spectator::Tags>: formatter<std::string_view> {
179+
template <> struct fmt::formatter<spectator::Tags>: fmt::formatter<std::string_view> {
190180
auto format(const spectator::Tags& tags, format_context& ctx) const -> format_context::iterator {
191181
std::string s;
192182
auto size = tags.size();
@@ -216,8 +206,18 @@ template <> struct fmt::formatter<spectator::Tags>: formatter<std::string_view>
216206
}
217207
};
218208

219-
template <> struct fmt::formatter<spectator::Id>: formatter<std::string_view> {
209+
inline auto operator<<(std::ostream& os, const spectator::Tags& tags) -> std::ostream& {
210+
os << fmt::format("{}", tags);
211+
return os;
212+
}
213+
214+
template <> struct fmt::formatter<spectator::Id>: fmt::formatter<std::string_view> {
220215
static auto format(const spectator::Id& id, format_context& ctx) -> format_context::iterator {
221216
return fmt::format_to(ctx.out(), "Id(name={}, tags={})", id.Name(), id.GetTags());
222217
}
223218
};
219+
220+
inline auto operator<<(std::ostream& os, const spectator::Id& id) -> std::ostream& {
221+
os << fmt::format("{}", id);
222+
return os;
223+
}

0 commit comments

Comments
 (0)