1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 21:01:16 +02:00

dropEmptyInitThenConcatStringsSep -> concatStringSep: empty separator

When the separator is empty, no difference is observable.

Note that concatStringsSep has centralized definitions. This adds the
required definitions. Alternatively, `strings-inline.hh` could be
included at call sites.
This commit is contained in:
Robert Hensing 2024-07-14 11:51:53 +02:00
parent d40fdb5711
commit 97e01107ec
2 changed files with 10 additions and 1 deletions

View file

@ -9,4 +9,11 @@ template std::string concatStringsSep(std::string_view, const Strings &);
template std::string concatStringsSep(std::string_view, const StringSet &); template std::string concatStringsSep(std::string_view, const StringSet &);
template std::string concatStringsSep(std::string_view, const std::vector<std::string> &); template std::string concatStringsSep(std::string_view, const std::vector<std::string> &);
typedef std::string_view strings_2[2];
template std::string concatStringsSep(std::string_view, const strings_2 &);
typedef std::string_view strings_3[3];
template std::string concatStringsSep(std::string_view, const strings_3 &);
typedef std::string_view strings_4[4];
template std::string concatStringsSep(std::string_view, const strings_4 &);
} // namespace nix } // namespace nix

View file

@ -11,6 +11,8 @@
#include <sstream> #include <sstream>
#include <optional> #include <optional>
#include "strings.hh"
namespace nix { namespace nix {
void initLibUtil(); void initLibUtil();
@ -69,7 +71,7 @@ auto concatStrings(Parts && ... parts)
-> std::enable_if_t<(... && std::is_convertible_v<Parts, std::string_view>), std::string> -> std::enable_if_t<(... && std::is_convertible_v<Parts, std::string_view>), std::string>
{ {
std::string_view views[sizeof...(parts)] = { parts... }; std::string_view views[sizeof...(parts)] = { parts... };
return dropEmptyInitThenConcatStringsSep({}, views); return concatStringsSep({}, views);
} }