about summary refs log tree commit diff stats
path: root/src/util.h
blob: 8cbe054b1434f78050cf237b5ada250c47a42aa3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef UTIL_H_440DEAA0
#define UTIL_H_440DEAA0

#include <string>
#include <sstream>
#include <memory>

namespace twitter {

  template <class InputIterator>
  std::string implode(InputIterator first, InputIterator last, std::string delimiter)
  {
    std::stringstream result;

    for (InputIterator it = first; it != last; it++)
    {
      if (it != first)
      {
        result << delimiter;
      }

      result << *it;
    }

    return result.str();
  }

};

#endif /* end of include guard: UTIL_H_440DEAA0 */