Fixed operator << for Easy::return_entity.

This commit is contained in:
tastytea 2019-04-21 13:17:39 +02:00
parent 7558c73648
commit d3d9f0f4e4
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
3 changed files with 10 additions and 19 deletions

View File

@ -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
*

View File

@ -63,14 +63,6 @@ Easy::return_entity<T>::return_entity::operator const string() const
return entity.to_string();
}
template<typename T>
std::ostream &Easy::operator <<(std::ostream &out,
const Easy::return_entity<T> &ret)
{
out << ret.entity.to_string();
return out;
}
// Explicit instantiations, so it can be used from outside.
template struct Easy::return_entity<Easy::Account>;
template struct Easy::return_entity<Easy::Application>;

View File

@ -36,11 +36,6 @@ namespace Mastodon
{
namespace Easy
{
template <typename T>
struct return_entity;
template <typename T> // https://stackoverflow.com/a/4661372/5965450
std::ostream &operator <<(std::ostream&, const return_entity<T>&);
/*!
* @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 <<<T>(std::ostream &out,
const return_entity<T> &ret);
friend std::ostream &operator <<(std::ostream &out,
const return_entity<T> &ret)
{
// Could only get it to work by implementing it here.
out << ret.entity.to_string();
return out;
}
};
/*!