Map Location: specialize steam operator for direction enum

This commit is contained in:
Charles Dang 2024-10-10 21:32:55 -04:00
parent c815e1d23a
commit c5069a6036
2 changed files with 11 additions and 0 deletions

View file

@ -37,6 +37,7 @@ std::ostream &operator<<(std::ostream &s, const map_location& l) {
s << (l.wml_x()) << ',' << (l.wml_y());
return s;
}
std::ostream &operator<<(std::ostream &s, const std::vector<map_location>& v) {
std::vector<map_location>::const_iterator i = v.begin();
for(; i!= v.end(); ++i) {
@ -45,6 +46,13 @@ std::ostream &operator<<(std::ostream &s, const std::vector<map_location>& v) {
return s;
}
/** Print a direction to stream. */
std::ostream& operator<<(std::ostream& s, map_location::direction dir)
{
s << map_location::write_direction(dir);
return s;
}
map_location::map_location(const config_attribute_value& x, const config_attribute_value& y, wml_loc)
: map_location(x.to_int(), y.to_int(), wml_loc{})
{

View file

@ -234,6 +234,9 @@ std::ostream &operator<<(std::ostream &s, const map_location& l);
/** Dumps a vector of positions on a stream, for debug purposes. */
std::ostream &operator<<(std::ostream &s, const std::vector<map_location>& v);
/** Print a direction's string representation to stream. */
std::ostream& operator<<(std::ostream& s, map_location::direction dir);
namespace std {
template<>
struct hash<map_location> {