Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.23)

project(spectator-cpp)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
Expand Down
24 changes: 12 additions & 12 deletions spectator/id.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ class Tags {
[[nodiscard]] table_t::const_iterator end() const { return entries_.end(); }
};

inline std::ostream& operator<<(std::ostream& os, const Tags& tags) {
os << fmt::format("{}", tags);
return os;
}

class Id {
public:
Id(absl::string_view name, Tags tags) noexcept
Expand Down Expand Up @@ -131,11 +126,6 @@ class Id {
}
}

friend std::ostream& operator<<(std::ostream& os, const Id& id) {
os << fmt::format("{}", id);
return os;
}

friend struct std::hash<Id>;

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

} // namespace std

template <> struct fmt::formatter<spectator::Tags>: formatter<std::string_view> {
template <> struct fmt::formatter<spectator::Tags>: fmt::formatter<std::string_view> {
auto format(const spectator::Tags& tags, format_context& ctx) const -> format_context::iterator {
std::string s;
auto size = tags.size();
Expand Down Expand Up @@ -216,8 +206,18 @@ template <> struct fmt::formatter<spectator::Tags>: formatter<std::string_view>
}
};

template <> struct fmt::formatter<spectator::Id>: formatter<std::string_view> {
inline auto operator<<(std::ostream& os, const spectator::Tags& tags) -> std::ostream& {
os << fmt::format("{}", tags);
return os;
}

template <> struct fmt::formatter<spectator::Id>: fmt::formatter<std::string_view> {
static auto format(const spectator::Id& id, format_context& ctx) -> format_context::iterator {
return fmt::format_to(ctx.out(), "Id(name={}, tags={})", id.Name(), id.GetTags());
}
};

inline auto operator<<(std::ostream& os, const spectator::Id& id) -> std::ostream& {
os << fmt::format("{}", id);
return os;
}