logoalt Hacker News

spacechild1 • today at 4:19 AM • 0 replies • view on HN

Exactly! When you have a `const std::string&` argument, passing a C-string implicitly allocates a new temporary `std::string`.

`std::string_view` accepts both `const std::string&` and `const char*` without hidden allocations.