Added functions to create a string from a vector

This commit is contained in:
2021-06-30 14:02:57 -04:00
parent 16b2a6f792
commit cf8fd4d65e
2 changed files with 92 additions and 26 deletions

View File

@@ -27,6 +27,7 @@
#include <cinttypes>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <unordered_map>
#include <map>
@@ -619,6 +620,21 @@ std::string toBin(T num){
return trimmedString;
}
//Print a vector
template <class T>
std::string printVector(std::vector<T>& ary){
std::stringstream str;
str << "[";
for(int cnt = 0;cnt < ary.size();++cnt){
str << ary[cnt];
if(cnt < ary.size() - 1){
str << ", ";
}
}
str << "]";
return str.str();
}
}