about summary refs log tree commit diff stats
path: root/src/util.h
blob: e1c937072ebd9713432b1ec289e19b4527d62745 (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
#ifndef UTIL_H_440DEAA0
#define UTIL_H_440DEAA0

#include <string>
#include <sstream>

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 */