Commit 83c2b26b authored by Dominik Charousset's avatar Dominik Charousset

provide two concrete overloads rather than a 'catch-all-template' to have a...

provide two concrete overloads rather than a 'catch-all-template' to have a clear distinction between std::to_string and cppa::to_string
parent 6a058c4d
...@@ -31,6 +31,9 @@ ...@@ -31,6 +31,9 @@
#ifndef CPPA_TO_STRING_HPP #ifndef CPPA_TO_STRING_HPP
#define CPPA_TO_STRING_HPP #define CPPA_TO_STRING_HPP
#include "cppa/atom.hpp" // included for to_string(atom_value)
#include "cppa/object.hpp"
#include "cppa/any_tuple.hpp"
#include "cppa/uniform_type_info.hpp" #include "cppa/uniform_type_info.hpp"
#include "cppa/detail/to_uniform_name.hpp" #include "cppa/detail/to_uniform_name.hpp"
...@@ -43,18 +46,17 @@ std::string to_string_impl(const void* what, const uniform_type_info* utype); ...@@ -43,18 +46,17 @@ std::string to_string_impl(const void* what, const uniform_type_info* utype);
} // namespace detail } // namespace detail
/** /**
* @brief Serializes a value to a string representation. * @brief Converts a tuple to a string.
* @param what A value of an announced type.
* @returns A string representation of @p what.
*/ */
template<typename T> inline std::string to_string(const any_tuple& what) {
std::string to_string(const T& what) { return detail::to_string_impl(&what, uniform_typeid<any_tuple>());
auto utype = uniform_typeid<T>(); }
if (utype == nullptr) {
throw std::logic_error( detail::to_uniform_name(typeid(T)) /**
+ " is not announced"); * @brief Converts an object to a string.
} */
return detail::to_string_impl(&what, utype); inline std::string to_string(const object& what) {
return detail::to_string_impl(what.value(), what.type());
} }
} // namespace cppa } // namespace cppa
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment