From d3d9f0f4e4a84490b1b1cefd6857e7dd1020b28a Mon Sep 17 00:00:00 2001 From: tastytea Date: Sun, 21 Apr 2019 13:17:39 +0200 Subject: [PATCH] Fixed operator << for Easy::return_entity. --- src/easy/entity.hpp | 2 +- src/easy/return_types_easy.cpp | 8 -------- src/easy/return_types_easy.hpp | 19 +++++++++---------- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/easy/entity.hpp b/src/easy/entity.hpp index 33058b6..4b38750 100644 --- a/src/easy/entity.hpp +++ b/src/easy/entity.hpp @@ -90,7 +90,7 @@ namespace Easy void from_string(const string &json); /*! - * @brief Returns the JSON of the Entity as string. + * @brief Returns the JSON of the Entity as formatted string. * * @return JSON string * diff --git a/src/easy/return_types_easy.cpp b/src/easy/return_types_easy.cpp index 55ea6d2..e09dc8f 100644 --- a/src/easy/return_types_easy.cpp +++ b/src/easy/return_types_easy.cpp @@ -63,14 +63,6 @@ Easy::return_entity::return_entity::operator const string() const return entity.to_string(); } -template -std::ostream &Easy::operator <<(std::ostream &out, - const Easy::return_entity &ret) -{ - out << ret.entity.to_string(); - return out; -} - // Explicit instantiations, so it can be used from outside. template struct Easy::return_entity; template struct Easy::return_entity; diff --git a/src/easy/return_types_easy.hpp b/src/easy/return_types_easy.hpp index 3ce5c6f..cd90af2 100644 --- a/src/easy/return_types_easy.hpp +++ b/src/easy/return_types_easy.hpp @@ -36,11 +36,6 @@ namespace Mastodon { namespace Easy { - template - struct return_entity; - template // https://stackoverflow.com/a/4661372/5965450 - std::ostream &operator <<(std::ostream&, const return_entity&); - /*! * @brief Return types for calls that return a single `Easy::Entity`. * @@ -79,20 +74,24 @@ namespace Easy operator const T() const; /*! - * @brief Mastodon::Easy::Entity as string. + * @brief Mastodon::Easy::Entity as formatted string. * * @since 0.100.0 */ operator const string() const; - // FIXME: Can't get it to work, don't know why. /*! - * @brief Mastodon::Easy::Entity as string. + * @brief Mastodon::Easy::Entity as formatted string. * * @since 0.100.0 */ - friend std::ostream &operator <<(std::ostream &out, - const return_entity &ret); + friend std::ostream &operator <<(std::ostream &out, + const return_entity &ret) + { + // Could only get it to work by implementing it here. + out << ret.entity.to_string(); + return out; + } }; /*!