Allow using splitStringSimple() with `std::unordered_set` in C++20
* So one could use e.g. `std::unordered_set<std::string_view>` as target container when splitting an `std::string_view`. * Still an experimental feature
This commit is contained in:
parent
d1e3a28277
commit
c61a1784ec
|
@ -114,7 +114,7 @@ set(META_APP_DESCRIPTION "Useful C++ classes and routines such as argument parse
|
|||
set(META_FEATURES_FOR_COMPILER_DETECTION_HEADER cxx_thread_local)
|
||||
set(META_VERSION_MAJOR 5)
|
||||
set(META_VERSION_MINOR 10)
|
||||
set(META_VERSION_PATCH 1)
|
||||
set(META_VERSION_PATCH 2)
|
||||
|
||||
# find required 3rd party libraries
|
||||
include(3rdParty)
|
||||
|
|
|
@ -194,7 +194,15 @@ Container splitStringSimple(const typename Container::value_type &string, const
|
|||
if (delimPos == Container::value_type::npos) {
|
||||
delimPos = string.size();
|
||||
}
|
||||
res.emplace_back(string.substr(i, delimPos - i));
|
||||
#if __cplusplus >= 202002
|
||||
if constexpr (requires { res.emplace_back(string); }) {
|
||||
#endif
|
||||
res.emplace_back(string.substr(i, delimPos - i));
|
||||
#if __cplusplus >= 202002
|
||||
} else {
|
||||
res.emplace(string.substr(i, delimPos - i));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue