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::basic_string::copy(3) C++ Standard Libary std::basic_string::copy(3)

std::basic_string::copy - std::basic_string::copy


size_type copy( CharT* dest, size_type count, size_type pos = 0 ) (until C++20)
const;
constexpr size_type copy( CharT* dest, size_type count, size_type pos (since C++20)
= 0 ) const;


Copies a substring [pos, pos+count) to character string pointed to by dest. If the
requested substring lasts past the end of the string, or if count == npos, the
copied substring is [pos, size()). The resulting character string is not
null-terminated.


If pos > size(), std::out_of_range is thrown.


dest - pointer to the destination character string
count - length of the substring
pos - position of the first character to include


number of characters copied


std::out_of_range if pos > size().


linear in count

// Run this code


#include <string>
#include <iostream>


int main()
{
std::string foo("quuuux");
char bar[7]{};
foo.copy(bar, sizeof bar);
std::cout << bar << '\n';
}


quuuux


substr returns a substring
(public member function)
copy copies characters
(C++17) (public member function of std::basic_string_view<CharT,Traits>)
copy copies a range of elements to a new location
copy_if (function template)
(C++11)
memcpy copies one buffer to another
(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.