Skip to content

Commit

Permalink
Clang fix: function order in string_utils.h.
Browse files Browse the repository at this point in the history
  • Loading branch information
PetterS committed Mar 13, 2014
1 parent f51bf4b commit 19361da
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions include/spii/string_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,8 @@ namespace spii
// and combinations thereof, e.g. vector<pair<int, string>>.
namespace {

void add_to_stream(std::ostream*)
{ }

template<typename T, typename... Args>
void add_to_stream(std::ostream* stream, T&& t, Args&&... args)
{
(*stream) << std::forward<T>(t);
add_to_stream(stream, std::forward<Args>(args)...);
}

std::string to_string()
{
return{};
}

// Overload for string literals.
template<size_t n>
std::string to_string(const char(&c_str)[n])
{
return{c_str};
}

template<typename... Args>
std::string to_string(Args&&... args)
{
std::ostringstream stream;
add_to_stream(&stream, std::forward<Args>(args)...);
return stream.str();
}

template<typename T1, typename T2>
std::ostream& operator<<(std::ostream& stream, std::pair<T1, T2> p)
std::ostream& operator<<(std::ostream& stream, const std::pair<T1, T2>& p)
{
stream << '(' << p.first << ", " << p.second << ')';
return stream;
Expand Down Expand Up @@ -140,6 +110,36 @@ namespace {
stream << ']';
return stream;
}

void add_to_stream(std::ostream*)
{ }

template<typename T, typename... Args>
void add_to_stream(std::ostream* stream, T&& t, Args&&... args)
{
(*stream) << std::forward<T>(t);
add_to_stream(stream, std::forward<Args>(args)...);
}

std::string to_string()
{
return{};
}

// Overload for string literals.
template<size_t n>
std::string to_string(const char(&c_str)[n])
{
return{c_str};
}

template<typename... Args>
std::string to_string(Args&&... args)
{
std::ostringstream stream;
add_to_stream(&stream, std::forward<Args>(args)...);
return stream.str();
}
}

template<typename T>
Expand Down

0 comments on commit 19361da

Please sign in to comment.