Permalink
Browse files

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

…have a clear distinction between std::to_string and cppa::to_string
  • Loading branch information...
1 parent 6a058c4 commit 83c2b26b3d05a6cb87398af4adaf6d6def991c7b @Neverlord Neverlord committed Sep 10, 2012
Showing with 13 additions and 11 deletions.
  1. +13 −11 cppa/to_string.hpp
View
@@ -31,6 +31,9 @@
#ifndef 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/detail/to_uniform_name.hpp"
@@ -43,18 +46,17 @@ std::string to_string_impl(const void* what, const uniform_type_info* utype);
} // namespace detail
/**
- * @brief Serializes a value to a string representation.
- * @param what A value of an announced type.
- * @returns A string representation of @p what.
+ * @brief Converts a tuple to a string.
*/
-template<typename T>
-std::string to_string(const T& what) {
- auto utype = uniform_typeid<T>();
- if (utype == nullptr) {
- throw std::logic_error( detail::to_uniform_name(typeid(T))
- + " is not announced");
- }
- return detail::to_string_impl(&what, utype);
+inline std::string to_string(const any_tuple& what) {
+ return detail::to_string_impl(&what, uniform_typeid<any_tuple>());
+}
+
+/**
+ * @brief Converts an object to a string.
+ */
+inline std::string to_string(const object& what) {
+ return detail::to_string_impl(what.value(), what.type());
}
} // namespace cppa

0 comments on commit 83c2b26

Please sign in to comment.