GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::vector::front(3) C++ Standard Libary std::vector::front(3)

std::vector::front - std::vector::front


reference front(); (until C++20)
constexpr reference front(); (since C++20)
const_reference front() const; (until C++20)
constexpr const_reference front() const; (since C++20)


Returns a reference to the first element in the container.


Calling front on an empty container is undefined.


(none)


reference to the first element


Constant


For a container c, the expression c.front() is equivalent to *c.begin().


The following code uses front to display the first element of a std::vector<char>:

// Run this code


#include <vector>
#include <iostream>


int main()
{
std::vector<char> letters {'o', 'm', 'g', 'w', 't', 'f'};


if (!letters.empty()) {
std::cout << "The first character is '" << letters.front() << "'.\n";
}
}


The first character is 'o'.


back access the last element
(public member function)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.