std::vector::flip(3)

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

πŸ’– std::vector::flip(3) πŸ’–

okay so this page lives in the C++ Standard Libary manual β€” yes, that's the spelling the source uses, and we are not gaslighting you about it β€” and it's all about std::vector::flip. bestie, it's a tiny member function with main character energy. πŸ’…


✨ NAME ✨

std::vector::flip - std::vector::flip


🌸 Synopsis 🌸

Defined in header <vector>

void flip();                (until C++20)
constexpr void flip();      (since C++20)

Toggles each bool in the vector (replaces with its opposite value).


πŸŽ€ Parameters πŸŽ€

  • (none) β€” no arguments, bestie. zero. nada. the void of parameters. 🫢

πŸ¦‹ Return value πŸ¦‹

  • (none) β€” it returns nothing. it's giving void energy. ✨

πŸ”₯ Example πŸ”₯

okay, run this code, it's literally right there:

       // Run this code

        #include <iostream>
        #include <vector>

        void print(const std::vector<bool>& vb)
        {
            for (const bool b : vb)
                std::cout << b;
            std::cout << '\n';
        }

        int main()
        {
            std::vector<bool> v{0, 1, 0, 1};
            print(v);
            v.flip();
            print(v);
        }

🌟 Output 🌟

0101
1010

πŸ‘‘ See also πŸ‘‘

  • operator[] β€” access specified element (public member function of std::vector<T,Allocator>)
  • flip β€” toggles the values of bits (public member function of std::bitset<N>)

source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: std::vector::flip(3) β€” k bye bestie, go flip some bools πŸ’–βœ¨

πŸ“¦ where this page comes from