diff options
Diffstat (limited to 'src/utils.h')
-rw-r--r-- | src/utils.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h index bdf7ddc..e44bdf2 100644 --- a/src/utils.h +++ b/src/utils.h @@ -29,6 +29,18 @@ namespace utils { } } + template<typename F, typename T> std::vector<std::shared_ptr<T>> castPtrs(std::vector<std::shared_ptr<F>> from) { + std::vector<std::shared_ptr<T>> Ts; + for(std::shared_ptr<F> f : from) { + std::shared_ptr<T> t = dynamic_pointer_cast<T>(f); + if(t) { + Ts.push_back(t); + } + } + return Ts; + } + + template<typename Container> std::string join(Container parts, std::string joiner) { std::stringstream out; bool isFirst = true; |