LearnFrenzy
Sign in Take a free test

Modern C++ Features (C++11 to C++23) · Modern C++ MCQ · Question 9

Ownership and lifetime of a string_view Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 9 Back to Exercise

Which statement about std::string_view is true?

  • A It copies the string
  • B It is a non-owning view (pointer + length); the viewed characters must outlive it Correct
  • C It is always null-terminated
  • D It can modify the string
Correct Answer: Option B

Its data() is not guaranteed to be null-terminated either.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links