std::experi..._view::data(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

🌸 NAME 🌸

So this is the std::experimental::basic_string_view::data page from the C++ Standard Libary manual β€” yes, the data(3) one β€” and it's lowkey a tiny but important little function, bestie. πŸ’…

std::experimental::basic_string_view::data gives you a pointer to the underlying character array.


✨ Synopsis ✨

constexpr const_pointer data() const noexcept;

This is the library fundamentals TS version. 🫢

It returns a pointer to the underlying character array. The pointer is such that the range [data(), data() + size()) is valid, and the values in that range correspond to the values of the view. ✨

n.b. Unlike basic_string::data() and string literals, data() may return a pointer to a buffer that is not null-terminated. So it's typically a mistake to pass data() to a routine that takes just a const CharT* and expects a null-terminated string. Like, do not do that, bestie. πŸ˜­πŸ’€

πŸŽ€ Parameters πŸŽ€

(none) β€” literally no parameters. Zero. Nada. ✨


🌈 Return value 🌈

A pointer to the underlying character array. That's the whole vibe. πŸ‘‘


⭐ Complexity ⭐

Constant. No surprises, no drama, just constant. πŸ’–


πŸ¦‹ See also πŸ¦‹

  • front β€” accesses the first character (public member function)
  • back β€” accesses the last character (public member function)

🌸 Category 🌸

  • Noindexed pages

That's the whole page, bestie β€” short, sweet, and absolutely iconic. πŸŽ€

Source/version and date sign-off: this one comes from http://cppreference.com, version/date 2024.06.10. Mwah. πŸ’‹βœ¨

πŸ“¦ where this page comes from