std::list::pop_front(3)

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

std::list::pop_front(3) πŸŽ€

okay so this is the std::list::pop_front page from the C++ Standard Libary manual (yes, that's the manual's spelling, bestie β€” not my typo πŸ’…). She's short, she's iconic, and she's here to remove exactly one thing from the front of your list.


🌸 NAME 🌸

std::list::pop_front β€” std::list::pop_front (she said what she said, and honestly? slay ✨).

✨ Synopsis ✨

void pop_front();

She removes the first element of the container. But bestie, listen: if there are no elements in the container, the behavior is undefined. That's undefined behavior territory, no cap β€” not a vibe to mess around with 😭.

Also important: references and iterators to the erased element are invalidated. They're done, they're invalidated, they're not coming to the group chat anymore πŸ’€.

🫢 Parameters 🫢

  • (none) β€” literally nothing. No arguments, no little extras, no notes. She's low-maintenance πŸ’–.

πŸ’– Return value πŸ’–

  • (none) β€” she returns nothing. The removal is the moment, and the moment is enough ✨.

πŸ¦‹ Complexity πŸ¦‹

Constant. Quick, constant, no drama β€” the way we like it πŸ’….

🌈 Exceptions 🌈

Does not throw. She's not throwing hands, she's not throwing exceptions. She's just popping the front and minding her business πŸŽ€.

πŸ“ Example πŸ“

// Run this code

#include <list>
#include <iostream>

int main()
{
    std::list<char> chars{'A', 'B', 'C', 'D'};

    for (; !chars.empty(); chars.pop_front())
        std::cout << "chars.front(): '" << chars.front() << "'\n";
}

⭐ Output ⭐

chars.front(): 'A'
chars.front(): 'B'
chars.front(): 'C'
chars.front(): 'D'

πŸ‘‘ See also πŸ‘‘

  • pop_back β€” removes the last element (public member function) πŸ’…
  • push_front β€” inserts an element to the beginning (public member function) ✨
  • front β€” access the first element (public member function) 🫢

that's the whole page, bestie πŸ’œ β€” brought to you by source/version http://cppreference.com, dated 2024.06.10, signing off with maximum sparkle πŸ§šβœ¨πŸ¦‹

πŸ“¦ where this page comes from