std::stack::operator=(3)

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

πŸ’– NAME πŸ’–

std::stack::operator= β€” std::stack::operator=

okay bestie, welcome to the std::stack::operator= page from the C++ Standard Libary manual β€” yes, that spelling is the manual name in the header, and we respect it πŸ’…. This whole page is about the assignment operator for std::stack, and it’s lowkey just: replace the contents of the container adaptor with the contents of the argument. Let’s go 🫢


✨ Synopsis ✨

          stack& operator=( const stack& other ); (1) (implicitly declared)
          stack& operator=( stack&& other );      (2) (since C++11)
                                                      (implicitly declared)

So what’s the vibe? The assignment operator replaces the contents of the container adaptor with the contents of the given argument. That’s the whole assignment moment ✨

  1. Copy assignment operator. Replaces the contents with a copy of the contents of other. Effectively calls c = other.c;.
  2. Move assignment operator. Replaces the contents with those of other using move semantics. Effectively calls c = std::move(other.c);.

Both are marked (implicitly declared) in the synopsis, and number 2 is (since C++11) β€” periodt πŸ’…


πŸŽ€ Parameters πŸŽ€

  • other β€” another container adaptor to be used as source

that’s the source, bestie 🫢


🌸 Return value 🌸

*this

that’s it, that’s the return πŸ’–


πŸ¦‹ Complexity πŸ¦‹

  • 1, 2) β€” Equivalent to that of operator= of the underlying container.

both numbers, same energy ✨


😭 Example 😭

This section is incomplete.

Reason: no example.

(yes, bestie, the example section is literally telling us there’s no example β€” not me staring at the void πŸ’€)


🌈 See also 🌈

  • constructor β€” constructs the stack (public member function)

🧚 Category 🧚

  • Todo: no example

mwah πŸ’‹ β€” source: http://cppreference.com; version/date: 2024.06.10; page: std::stack::operator=(3). byeee 🫢✨

πŸ“¦ where this page comes from