Skip to content

Commit

Permalink
Added function to convert vector to string
Browse files Browse the repository at this point in the history
  • Loading branch information
einar90 committed Nov 22, 2016
1 parent c917148 commit 3c4d4fa
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions FieldOpt/Utilities/stringhelpers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/// This file contains helper methods for working with time.
#ifndef STRINGHELPERS_FUNCTIONS_H
#define STRINGHELPERS_FUNCTIONS_H

#include <string>
#include <vector>

using namespace std;

template <typename T>
inline string vec_to_str(vector<T> vec) {
string str = "";
if (vec.size() == 0) return str;
str = to_string(vec[0]);
if (vec.size() > 1) {
for (int i = 1; i < vec.size(); ++i) {
str = str + ", " + to_string(vec[i]);
}
}
return str;
}

#endif // STRINGHELPERS_FUNCTIONS_H

0 comments on commit 3c4d4fa

Please sign in to comment.