My way (without additional branch) is:
const auto separator = "WhatYouWantHere";
const auto* sep = "";
for(const auto& item : items) {
std::cout << sep << item;
sep = separator;
}
More Related Contents:
- C++ 11: conversion const int* to int* using unordered_set::push
- Undefined reference to static constexpr char[]
- How do I check for C++11 support?
- Do rvalue references to const have any use?
- Is the safe-bool idiom obsolete in C++11?
- Compile time string hashing
- How to succinctly, portably, and thoroughly seed the mt19937 PRNG?
- Why can’t simple initialize (with braces) 2D std::array? [duplicate]
- Is is_constexpr possible in C++11?
- Resolution of std::chrono::high_resolution_clock doesn’t correspond to measurements
- Capturing a reference by reference in a C++11 lambda
- std::map emplace without copying value
- When to use std::begin and std::end instead of container specific versions [duplicate]
- How to enable C++11 in CLion?
- Garbage Collection in C++ — why?
- What are the main purposes of std::forward and which problems does it solve?
- C++ Modules – why were they removed from C++0x? Will they be back later on?
- Which headers in the C++ standard library are guaranteed to include another header?
- Default template argument when using std::enable_if as templ. param.: why OK with two template functions that differ only in the enable_if parameter?
- How can an incomplete type be used as a template parameter to vector here?
- When Does Move Constructor get called?
- Questions about Hinnant’s stack allocator
- Equivalent of “using namespace X” for scoped enumerations?
- The implementation of random_device in VS2010?
- Implementation of Permutation, Combinations and PowerSet in C++ [duplicate]
- Idiomatic Way to declare C++ Immutable Classes
- std::this_thread::sleep_for() and GCC
- Why isn’t std::array::size static?
- Why is reinterpret_cast not constexpr?
- How to initialize all tuple elements by the same arguments?