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::move_iterator::operator[](3) C++ Standard Libary std::move_iterator::operator[](3)

std::move_iterator::operator[] - std::move_iterator::operator[]


/*unspecified*/ operator[]( difference_type n ) const; (since C++11)
(until C++17)
constexpr /*unspecified*/ operator[]( difference_type n ) const; (since C++17)


Returns a reference to the element at specified relative location.


n - position relative to current location.


An rvalue reference to the element at relative location, that is,
std::move(base()[n])
(until C++20)
ranges::iter_move(base() + n)
(since C++20).

// Run this code


#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <string>
#include <vector>


void print(auto rem, auto const& v) {
for (std::cout << rem; auto const& e : v)
std::cout << quoted(e) << ' ';
std::cout << '\n';
}


int main()
{
std::vector<std::string> p{"alpha", "beta", "gamma", "delta"}, q;
print("1) p: ", p);


std::move_iterator it{p.begin()};


for (size_t t{0U}; t != p.size(); ++t) {
q.emplace_back( it[t] );
}


print("2) p: ", p);
print("3) q: ", q);


std::list l{1,2,3};
std::move_iterator it2{l.begin()};
// it2[1] = 13; // compilation error ~ the underlying iterator
// does not model the random access iterator
// *it2 = 999; // compilation error: using rvalue as lvalue
}


1) p: "alpha" "beta" "gamma" "delta"
2) p: "" "" "" ""
3) q: "alpha" "beta" "gamma" "delta"


operator*
operator-> accesses the pointed-to element
(C++11) (public member function)
(C++11)(deprecated in C++20)

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.