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

std::return_temporary_buffer - std::return_temporary_buffer


Defined in header <memory>
template< class T > (deprecated in C++17)
void return_temporary_buffer( T* p ); (removed in C++20)


Deallocates storage previously allocated with std::get_temporary_buffer.


p - the pointer previously returned by std::get_temporary_buffer and not invalidated
by an earlier call to return_temporary_buffer


(none)


Throws nothing.

// Run this code


#include <algorithm>
#include <iostream>
#include <memory>
#include <string>
#include <iterator>


int main()
{
const std::string s[] = {"string", "1", "test", "..."};
const auto p = std::get_temporary_buffer<std::string>(4);
// requires that p.first is passed to return_temporary_buffer
// (beware of early exit points and exceptions)


std::copy(s, s + p.second,
std::raw_storage_iterator<std::string*, std::string>(p.first));
// has same effect as: std::uninitialized_copy(s, s + p.second, p.first);
// requires that each string in p is individually destroyed
// (beware of early exit points and exceptions)


std::copy(p.first, p.first + p.second,
std::ostream_iterator<std::string>{std::cout, "\n"});


std::for_each(p.first, p.first + p.second, [](std::string& e) {
e.~basic_string<char>();
}); // same as: std::destroy(p.first, p.first + p.second);


std::return_temporary_buffer(p.first);
}


string
1
test
...


get_temporary_buffer obtains uninitialized storage
(deprecated in C++17) (function template)
(removed 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.