summaryrefslogtreecommitdiff
path: root/src/a2functional.h
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-06-06 12:48:05 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-06-06 12:48:05 +0000
commita8c278d026580032b861eb8e7287dc7263bb4432 (patch)
treeb49339dd2f9d8b8cd1d62d89fc718f7ae07779fd /src/a2functional.h
parent3bb2e3b07ec34322996fa5bb5b70c5721482c5c0 (diff)
2009-06-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added strjoin function template. Use it in pathJoin() * src/Util.h * src/a2functional.h
Diffstat (limited to 'src/a2functional.h')
-rw-r--r--src/a2functional.h29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/a2functional.h b/src/a2functional.h
index 1ed75509..9809b36a 100644
--- a/src/a2functional.h
+++ b/src/a2functional.h
@@ -165,18 +165,6 @@ public:
}
};
-class Concat {
-private:
- std::string _delim;
-public:
- Concat(const std::string& delim = A2STR::NIL):_delim(delim) {}
-
- std::string operator()(const std::string& s1, const std::string& s2) const
- {
- return s1+_delim+s2;
- }
-};
-
class Deleter {
public:
template<class T>
@@ -216,6 +204,23 @@ public:
}
};
+template<typename InputIterator, typename DelimiterType>
+std::string strjoin(InputIterator first, InputIterator last,
+ const DelimiterType& delim)
+{
+ std::string result;
+ if(first == last) {
+ return result;
+ }
+ InputIterator beforeLast = last-1;
+ for(; first != beforeLast; ++first) {
+ result += *first;
+ result += delim;
+ }
+ result += *beforeLast;
+ return result;
+}
+
template<typename T1, typename T2>
inline std::string strconcat(const T1& a1, const T2& a2)
{