Skip to content

Commit

Permalink
libnixt/serialize: workaround for libcxx .view()
Browse files Browse the repository at this point in the history
  • Loading branch information
inclyc committed Dec 30, 2023
1 parent 19fa773 commit 45f23ac
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion libnixt/include/nixt/SerializeSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,18 @@ std::size_t write(std::ostream &OS, const T &Data) {
class StringTable {
public:
std::size_t write(std::string Str);
std::string_view view() { return OS.view(); }

// __WORKAROUND__
// libcxx implements .view in recent patch:
// https://github.com/llvm/llvm-project/commit/81ad5a5cb87740c62b30a4f8232770bd5eb7fc45
// So on macOS this is not available.
std::string_view view() {
#if defined(__GLIBCXX__)
return OS.view();
#else
return OS.rdbuf()->view();
#endif
}

private:
std::map<std::string, std::size_t> Map;
Expand Down

0 comments on commit 45f23ac

Please sign in to comment.