mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-18 02:08:09 +08:00
add concat_to_string to utility for error messges
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "traits.hpp"
|
||||
#include <utility>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
|
||||
namespace toml
|
||||
{
|
||||
@@ -30,7 +31,7 @@ inline void resize_impl(T& container, std::size_t N, std::false_type)
|
||||
else throw std::invalid_argument("not resizable type");
|
||||
}
|
||||
|
||||
}
|
||||
} // detail
|
||||
|
||||
template<typename T>
|
||||
inline void resize(T& container, std::size_t N)
|
||||
@@ -39,5 +40,27 @@ inline void resize(T& container, std::size_t N)
|
||||
else return detail::resize_impl(container, N, detail::has_resize_method<T>());
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
inline std::string concat_to_string_impl(std::ostringstream& oss)
|
||||
{
|
||||
return oss.str();
|
||||
}
|
||||
template<typename T, typename ... Ts>
|
||||
std::string concat_to_string_impl(std::ostringstream& oss, T&& head, Ts&& ... tail)
|
||||
{
|
||||
oss << std::forward<T>(head);
|
||||
return concat_to_string_impl(oss, std::forward<Ts>(tail) ... );
|
||||
}
|
||||
} // detail
|
||||
|
||||
template<typename ... Ts>
|
||||
std::string concat_to_string(Ts&& ... args)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << std::boolalpha << std::fixed;
|
||||
return detail::concat_to_string_impl(oss, std::forward<Ts>(args) ...);
|
||||
}
|
||||
|
||||
}// toml
|
||||
#endif // TOML11_UTILITY
|
||||
|
Reference in New Issue
Block a user