Varianti

std::list::begin, std::list::cbegin

Da cppreference.com.
 
 
 
std::list
Membri funzioni
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
list::list
list::~list
list::operator=
list::assign
list::get_allocator
Elemento accesso
Original:
Element access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
list::front
list::back
Iteratori
Original:
Iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
list::begin
list::cbegin

(C++11)
list::end
list::cend

(C++11)
list::rbegin
list::crbegin

(C++11)
list::rend
list::crend

(C++11)
Capacità
Original:
Capacity
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
list::empty
list::size
list::max_size
Modificatori
Original:
Modifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
list::clear
list::insert
list::emplace(C++11)
list::erase
list::push_front
list::emplace_front(C++11)
list::pop_front
list::push_back
list::emplace_back(C++11)
list::pop_back
list::resize
list::swap
Operazioni
Original:
Operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
list::merge
list::splice
list::remove
list::remove_if
list::reverse
list::unique
list::sort
 
<tbody> </tbody> <tbody class="t-dcl-rev "> </tbody><tbody> </tbody> <tbody class="t-dcl-rev "> </tbody><tbody> </tbody>
iterator begin();
(fino al c++11)
iterator begin() noexcept;
(dal C++11)
const_iterator begin() const;
(fino al c++11)
const_iterator begin() const noexcept;
(dal C++11)
const_iterator cbegin() const noexcept;

Restituisce un iteratore al primo elemento del container.

Se il container è vuoto, l'iteratore restituito sarà uguale a end().

Parametri

(nessuno)

Valore restituito

Iteratore al primo elemento

Complessità

Costante


Example

#include <iostream>
#include <list>
#include <string>

int main()
{
	std::list<int> ints {1, 2, 4, 8, 16};
	std::list<std::string> fruits {"orange", "apple", "raspberry"};
	std::list<char> empty;

	// Sums all integers in the list ints (if any), printing only the result.
	int sum = 0;
	for (auto it = ints.cbegin(); it != ints.cend(); it++)
		sum += *it;
	std::cout << "Sum of ints: " << sum << "\n";

	// Prints the first fruit in the list fruits, without checking if there is one.
	std::cout << "First fruit: " << *fruits.begin() << "\n";

	if (empty.begin() == empty.end())
		std::cout << "list 'empty' is indeed empty.\n";
}

Output:

Sum of ints: 31
First fruit: orange
list 'empty' is indeed empty.

Vedi anche

restituisce un iteratore fino alla fine
Original:
returns an iterator to the end
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(metodo pubblico) [modifica]