Allow specifying return type in joinStrings()
for joining an std::string from an std::vector<std::string_view>.
This commit is contained in:
parent
84011c2768
commit
b363498f53
|
@ -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_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_FEATURES_FOR_COMPILER_DETECTION_HEADER cxx_thread_local)
|
||||||
set(META_VERSION_MAJOR 5)
|
set(META_VERSION_MAJOR 5)
|
||||||
set(META_VERSION_MINOR 5)
|
set(META_VERSION_MINOR 6)
|
||||||
set(META_VERSION_PATCH 0)
|
set(META_VERSION_PATCH 0)
|
||||||
|
|
||||||
# find required 3rd party libraries
|
# find required 3rd party libraries
|
||||||
|
|
|
@ -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.
|
* \tparam Container The STL-container used to provide the \a strings.
|
||||||
* \returns Returns the joined string.
|
* \returns Returns the joined string.
|
||||||
*/
|
*/
|
||||||
template <class Container = std::initializer_list<std::string>>
|
template <class Container = std::initializer_list<std::string>, class ReturnType = typename Container::value_type>
|
||||||
typename Container::value_type joinStrings(const Container &strings,
|
ReturnType joinStrings(const Container &strings, const typename Container::value_type &delimiter = typename Container::value_type(),
|
||||||
const typename Container::value_type &delimiter = typename Container::value_type(), bool omitEmpty = false,
|
bool omitEmpty = false, const typename Container::value_type &leftClosure = typename Container::value_type(),
|
||||||
const typename Container::value_type &leftClosure = typename Container::value_type(),
|
|
||||||
const typename Container::value_type &rightClosure = typename Container::value_type())
|
const typename Container::value_type &rightClosure = typename Container::value_type())
|
||||||
{
|
{
|
||||||
typename Container::value_type res;
|
ReturnType res;
|
||||||
if (!strings.size()) {
|
if (!strings.size()) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue