Allow specifying return type in joinStrings()

for joining an std::string from an std::vector<std::string_view>.
This commit is contained in:
Martchus 2020-07-25 22:53:46 +02:00
parent 84011c2768
commit b363498f53
2 changed files with 5 additions and 6 deletions

View File

@ -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

View File

@ -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 <class Container = std::initializer_list<std::string>>
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 Container = std::initializer_list<std::string>, 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;
}