String view outlives source
Review this C++ code using std::string_view.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.
0:00 of about 30 min
Mark a line and say what kind of problem it is.0 findings
1#include <string>
2#include <string_view>
3
4std::string make_name(int id) {
5 return "user-" + std::to_string(id);
6}
7
8void run(int id) {
9 std::string_view sv = make_name(id);
10 // ... later ...
11 process(sv); // takes std::string_view
12}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.