#ifndef __x_to_string_h__ #define __x_to_string_h__ #include #include #include #include namespace MultiArrayHelper { template inline std::string xToString(const T& x) { return std::to_string(x); } template struct TupleToString { template static inline std::string mk(const std::tuple& tp) { return TupleToString::mk(tp) + " , " + xToString(std::get(tp)); } }; template <> struct TupleToString<0> { template static inline std::string mk(const std::tuple& tp) { return xToString(std::get<0>(tp)); } }; template <> inline std::string xToString(const char& x) { std::string out = ""; return out += x; } template <> inline std::string xToString(const std::string& x) { return x; } template inline std::string xToString(const std::vector& x) { std::string out = "[ "; for(auto& y: x){ out += y + " , "; } out.pop_back(); out.back() = ']'; return out; } template inline std::string xToString(const std::array& x) { std::string out = "[ "; for(auto& y: x){ out += y + " , "; } out.pop_back(); out.back() = ']'; return out; } template inline std::string xToString(const std::tuple& tp) { return "{ " + TupleToString::mk(tp) + " }"; } } #endif