From b363498f53d82892618792521600b363a335be5c Mon Sep 17 00:00:00 2001 From: Martchus Date: Sat, 25 Jul 2020 22:53:46 +0200 Subject: [PATCH] Allow specifying return type in joinStrings() for joining an std::string from an std::vector. --- CMakeLists.txt | 2 +- conversion/stringconversion.h | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 60c2031..2421772 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,7 +113,7 @@ set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}") set(META_APP_DESCRIPTION "Useful C++ classes and routines such as argument parser, IO and conversion utilities") set(META_FEATURES_FOR_COMPILER_DETECTION_HEADER cxx_thread_local) set(META_VERSION_MAJOR 5) -set(META_VERSION_MINOR 5) +set(META_VERSION_MINOR 6) set(META_VERSION_PATCH 0) # find required 3rd party libraries diff --git a/conversion/stringconversion.h b/conversion/stringconversion.h index fdbc1dc..f059a5f 100644 --- a/conversion/stringconversion.h +++ b/conversion/stringconversion.h @@ -71,13 +71,12 @@ CPP_UTILITIES_EXPORT void truncateString(std::string &str, char terminationChar * \tparam Container The STL-container used to provide the \a strings. * \returns Returns the joined string. */ -template > -typename Container::value_type joinStrings(const Container &strings, - const typename Container::value_type &delimiter = typename Container::value_type(), bool omitEmpty = false, - const typename Container::value_type &leftClosure = typename Container::value_type(), +template , class ReturnType = typename Container::value_type> +ReturnType joinStrings(const Container &strings, const typename Container::value_type &delimiter = typename Container::value_type(), + bool omitEmpty = false, const typename Container::value_type &leftClosure = typename Container::value_type(), const typename Container::value_type &rightClosure = typename Container::value_type()) { - typename Container::value_type res; + ReturnType res; if (!strings.size()) { return res; }