Commit e44d5ab3 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Add helper to copy-transform a string, wrapping std::transform

parent 3f73ba43
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -127,6 +127,15 @@ namespace allpix {
     * @return List of all the substrings with all empty substrings ignored (thus removed)
     */
    template <typename T> std::vector<T> split(std::string str, const std::string& delims = " \t,");

    /**
     * @brief Transforms a string and returns the transformed string
     * @param str String that should be transformed
     * @param op Unary operator to act on the string
     * @return Transformed string
     */
    template <typename T> std::string transform(const std::string& str, const T& op);

} // namespace allpix

// Include template definitions
+6 −0
Original line number Diff line number Diff line
@@ -132,4 +132,10 @@ namespace allpix {

        return elems;
    }

    template <typename T> std::string transform(const std::string& str, const T& op) {
        auto output = str;
        std::transform(output.begin(), output.end(), output.begin(), op);
        return output;
    }
} // namespace allpix