This documentation is automatically generated by competitive-verifier/competitive-verifier
#include "tools/join.hpp"
template <std::ranges::range R, typename T>
std::string join(R e, T d);
Given $n$ elements $e_0, e_1, \cdots, e_{n - 1}$, it returns $e_0 + d + e_1 + d + \cdots + d + e_{n - 1}$ where $+$ is string concatenation. Note that it returns an empty string if $n = 0$.
operator<<(std::ostream, std::ranges::range_value_t<R>)
is defined.operator<<(std::ostream, T)
is defined.#ifndef TOOLS_JOIN_HPP
#define TOOLS_JOIN_HPP
#include <ranges>
#include <sstream>
namespace tools {
template <::std::ranges::range R, typename T>
::std::string join(R&& e, const T& d) {
::std::ostringstream ss;
auto it = ::std::ranges::begin(e);
const auto end = ::std::ranges::end(e);
if (it != end) {
ss << *it;
for (++it; it != end; ++it) {
ss << d << *it;
}
}
return ss.str();
}
}
#endif
#line 1 "tools/join.hpp"
#include <ranges>
#include <sstream>
namespace tools {
template <::std::ranges::range R, typename T>
::std::string join(R&& e, const T& d) {
::std::ostringstream ss;
auto it = ::std::ranges::begin(e);
const auto end = ::std::ranges::end(e);
if (it != end) {
ss << *it;
for (++it; it != end; ++it) {
ss << d << *it;
}
}
return ss.str();
}
}