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

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

πŸ’… std::experi..._view::copy(3) πŸŽ€

okay so this page is from the C++ Standard Library manual, and it's literally all about std::experimental::basic_string_view::copy. yes bestie, that whole entire name, we're not shortening it, it's iconic and it's staying.


✨ NAME ✨

std::experimental::basic_string_view::copy β€” like, that's the function, that's the whole name, no notes 🫢


🌸 SYNOPSIS 🌸

size_type copy( CharT* dest,

                size_type count,           (library fundamentals TS)

                size_type pos = 0) const;

so the vibe here is: it copies the substring [pos, pos + rcount) over to the character string that dest is pointing at, and rcount is the smaller of count and size() - pos. that's the whole bit. lowkey elegant ngl πŸ’œ


πŸ¦‹ PARAMETERS πŸ¦‹

  • dest β€” pointer to the destination character string, a.k.a. where the good stuff goes ✨
  • pos β€” position of the first character, like where you're starting from in the story πŸŽ€
  • count β€” requested substring length, i.e. how much you're asking for πŸ’«

⭐ RETURN VALUE ⭐

number of characters copied. that's it, that's the answer, no drama πŸ‘‘


πŸ”₯ EXCEPTIONS πŸ”₯

it throws std::out_of_range if pos > size(). so like, if you're trying to start past the end of the string, it WILL call you out and you will be perceived 😭


🌈 COMPLEXITY 🌈

linear in rcount. so the more you copy, the longer it takes β€” math is mathing, no cap πŸ’€


πŸ“ SEE ALSO πŸ“

  • substr β€” returns a substring (public member function) β€” the little sibling energy is real, go check it out bestie πŸ’–

🧚 CATEGORY 🧚

  • Noindexed pages (she's mysterious, she's not indexed, we respect it πŸ™ˆ)

heads up bestie: this whole thing is the library fundamentals TS version, so keep that in mind before you go copying it into your main character production code πŸ’…

sign-off time 🫢 this lil cutie lives over at http://cppreference.com, dated 2024.06.10, and that's the tea β˜• periodt βœ¨πŸŽ€πŸ’œ

πŸ“¦ where this page comes from