mirror of
https://github.com/NixOS/nix
synced 2025-07-05 12:21:48 +02:00
MacOS built: add workaround for missing view() member of std::ostringstream
This commit is contained in:
parent
caf3b55891
commit
e21c7895eb
11 changed files with 39 additions and 19 deletions
|
@ -6,6 +6,21 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
struct view_stringbuf : public std::stringbuf
|
||||
{
|
||||
inline std::string_view toView()
|
||||
{
|
||||
auto begin = pbase();
|
||||
return {begin, begin + pubseekoff(0, std::ios_base::cur, std::ios_base::out)};
|
||||
}
|
||||
};
|
||||
|
||||
std::string_view toView(const std::ostringstream & os)
|
||||
{
|
||||
auto buf = static_cast<view_stringbuf *>(os.rdbuf());
|
||||
return buf->toView();
|
||||
}
|
||||
|
||||
template std::list<std::string> tokenizeString(std::string_view s, std::string_view separators);
|
||||
template std::set<std::string> tokenizeString(std::string_view s, std::string_view separators);
|
||||
template std::vector<std::string> tokenizeString(std::string_view s, std::string_view separators);
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
/*
|
||||
* workaround for unavailable view() method (C++20) of std::ostringstream under MacOS with clang-16
|
||||
*/
|
||||
std::string_view toView(const std::ostringstream & os);
|
||||
|
||||
/**
|
||||
* String tokenizer.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue