
That's pretty straightforward with another overload: auto& s = join(to(y), separator(", "), "A", "b", 42); where to(y) is something like template<String> struct to_existing_type<String> { String& get() { return s_; } String s_; }; template<class String> auto to(String& s) { return to_existing_type<S>(s); } With a bit of template unwrapping, we could imagine something like this: join(to(x), 2, 3, to(y), "foo", "bar", create(), "baz", 42); which would return a tuple: std::tuple<std::string&, std::string&, std::string> in c++17 this would allow: auto&& [x, y, z] = join(to(x), 2, 3, to(y), "foo", "bar", create(), "baz", 42); But this maybe taking it a bit far... What do you think? On 18 January 2017 at 09:06, Olaf van der Spek <ml@vdspek.org> wrote:
On Mon, Jan 16, 2017 at 11:41 AM, Richard Hodges <hodges.r@gmail.com> wrote:
Sorry to chime in so late in the discussion.
What about a syntax similar to this?
int main() { auto s = join("Hello ", ", World.", " The hex for ", 58, " is ", std::hex, 58); std::cout << s << std::endl;
s = join(separator(" : "), "a", "b", std::hex, 200 , std::quoted("banana")); std::cout << s << std::endl;
}
Which would produce the following output:
Hello , World. The hex for 58 is 3a a : b : c8 : “banana"
The syntax is fine but it's missing an appending variant, like append(s, "A", "B", 42); This variant is important as it (also) allows you to reuse existing storage.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/ mailman/listinfo.cgi/boost