“Enough string_view to Hang Ourselves”
summary
Argues that std::string_view is a useful zero-copy glue for mixed string APIs but repeatedly causes real bugs: dangling references from storing views, a surprising implicit conversion path where std::string’s new templated constructor accepts a string_view, and subtle auto traps that bind views to temporary concatenation results. Shows static checks (clang-tidy’s bugprone-dangling-handle and clang -Wlifetime) catching many cases, recommends restrict views to parameter use, document returns, and avoid storing or implicit conversions.
AI-written summary · about
chapters (13)
- 0:00Start
- 0:26Road Map
- 1:09Why Are We Talking about String View
- 7:13Alternatives
- 8:05The Abseil Project
- 15:54Storing String Views
- 17:59Get Frequency from Keyword
- 20:21The Sink Idiom
- 33:11Client Power Tools
- 34:06Bug Prone Dangling Handle
- 47:18Borrow Type
- 49:22Problem with String View
- 59:18What's the Benefit of String Views
related talks
01h 00mEnough string_view to hang ourselves
05mLightning Talks: -std=c++20 -- Will This C++ Code Compile?
29mCan't Touch This! What not to do to the DOM
24mThe Philosopher's String
01h 00mCatch ⬆️: Unicode for C++23
26mDesign Suggestions for XML++
34mStrings Seven Ways
01h 44mImplementing advanced DOM manipulation scenarios
