std::swap(s...tringstream)(3)

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

πŸ’… std::swap(std::basic_istringstream) πŸ’…

okay bestie so this page lives in the C++ Standard Library manual (yes, the whole std::swap(s...tringstream)(3) situation) and it's honestly a tiny little glow-up of a function. let me break it down 🫢


✨ NAME ✨

std::swap(std::basic_istringstream) β€” literally what it says on the tin: the swap for std::basic_istringstream. no cap, that's the whole name, twice, because the manpage said it twice and I would never gatekeep a single character from you πŸ’–


🌸 Synopsis 🌸

okay so, this one's Defined in header <sstream> β€” that's where it lives, don't forget to include it or nothing works, periodt.

template< class CharT, class Traits, class Alloc >

void swap( std::basic_istringstream<CharT,Traits,Alloc>& lhs,
(since C++11)

           std::basic_istringstream<CharT,Traits,Alloc>& rhs );

so what does it do? it Overloads the std::swap algorithm for std::basic_istringstream. β€” like, it's the special swap just for these stream girls πŸ‘‘

it Exchanges the state of lhs with that of rhs. β€” effectively calls lhs.swap(rhs). that's it, that's the vibe. two streams trade states, everyone goes home happy ✨

quick note bestie: this overload is (since C++11) β€” if you're time-traveling to C++03, this one's not there for you 😭

πŸŽ€ Parameters πŸŽ€

  • lhs, rhs β€” streams whose state to swap β€” yeah, just the two streams swapping their whole situation. give them a minute πŸ™ˆ

πŸ¦‹ Return value πŸ¦‹

(none) β€” nothing comes back. void behavior, zero notes, it just does the thing πŸ’…


⭐ Exceptions ⭐

May throw implementation-defined exceptions. β€” so like, it might throw, and what exactly it throws depends on your implementation. no promises, no cap, just vibes πŸ”₯


🌈 Example 🌈

big yikes: This section is incomplete

Reason: no example 😭😭 the manpage really said "figure it out bestie" β€” so yeah, there's no example here. not me crying over an empty example section fr fr πŸ’€


πŸ’œ See also πŸ’œ

  • swap β€” swaps two string streams, and it's a (C++11) public member function. that's the member-function bestie to this free-function one 🫢

πŸ‘‘ Category πŸ‘‘

  • * Todo no example

like, the category itself is calling out the missing example. it's giving self-aware 😭


okay that's the whole page, you ate that, no crumbs left πŸ“ this iconic little doc came from http://cppreference.com, dated 2024.06.10, and it's filed under std::swap(s...tringstream)(3) β€” go forth and swap those stream states, bestie πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from