◐ Shell
clean mode source ↗

std::set::begin, std::set::cbegin – cppreference.com

Z cppreference.com

<tbody> </tbody> <tbody class="t-dcl-rev "> </tbody><tbody> </tbody> <tbody class="t-dcl-rev "> </tbody><tbody> </tbody>

iterator begin();

(do C++11)

iterator begin() noexcept;

(od C++11)

const_iterator begin() const;

(do C++11)

const_iterator begin() const noexcept;

(od C++11)

const_iterator cbegin() const noexcept;

(od C++11)

Zwraca iterator na pierwsy element kontenera.

Jeśli kontener jest pusty, zwrócony iterator ma wartość równą end().

Parametry

(brak)

Zwracana wartość

Iterator na pierwszy element

Złożoność

Stała

Przykład

#include <set>
#include <iostream>
 
int main() {
  std::set<int> set = { 6, 1, 3, 4, 2, 5 };
  for (auto it = set.begin(); it != set.end(); ++it)
    std::cout << *it << "\n";
}

Możliwy wynik:

Zobacz także

zwraca iterator za koniec kontenera
(publiczna metoda) [edit]