获取一块临时内存。在C ++ STL库中,有一个函数get_temporary_buffer,该函数主要用于获取临时块。 该函数的大小为n,并返回最大大小为n的可用缓冲区,该缓冲区可以装入物理内存。 此函数用于获取临时性质的内存,该内存主要用于算法的操作,因为某些算法需要额外的空间才能正确执行。
{int i; pair<char*, ptrdiff_t> p = get_temporary_buffer<char>(n);// copy the contents in temporary buffer with pairuninitialized_copy(b, b + p.second, p.first);// sort char arraysort(p.first, p.first + p.second); cout << "sorted characters are :" << endl;for (i = 0; ...
template<class Type> pair<Type *, ptrdiff_t> get_temporary_buffer( ptrdiff_t _Count ); 参数 _Count 将哪内存请求的元素的最大数目。 返回值 第一个元素是指向内存分配,因此,第二个元素提供的缓冲区的大小,指示元素的大量它所能存储的 pair。 备注 函数创建一个内存要求,可能会失败。 如果未分配缓冲...
}; const auto p = std::get_temporary_buffer<std::string>(4); // 要求将 p.first 传递给 return_temporary_buffer // (当心提前退出和异常),或者更应该使用: std::unique_ptr<std::string, void(*)(std::string*)> on_exit(p.first, [](std::string* p) { std::cout << "返还临时缓冲...
一、背景介绍: 函数指针始终不太灵活,它只能指向全局或静态函数,对于类成员函数、lambda表达式或其他可...
std::get_temporary_buffer std::return_temporary_buffer std::uninitialized_copy std::uninitialized_fill std::uninitialized_default_construct std::uninitialized_copy_n std::uninitialized_fill_n std::uninitialized_move_n std::uninitialized_default_construct_n std::uninitialized_value_construct_n std::con...
template<class Type> pair<Type *, ptrdiff_t> get_temporary_buffer( ptrdiff_t _Count ); Paramètres_Count Le nombre maximal d'éléments demandés de la mémoire doit être allouée.Valeur de retourpair dont le premier composant est un pointeur vers la mémoire allouée, et dont le deuxième...
獲取一塊臨時內存。在C++ STL庫中,有一個函數get_temporary_buffer,該函數主要用於獲取臨時塊。 此函數的大小為n,並返回最大大小為n的可用緩衝區,該緩衝區可以裝入物理內存。 此函數用於獲取臨時性質的內存,該內存主要用於算法的操作,因為某些算法需要額外的空間才能正確執行。
template<class Type> pair<Type *, ptrdiff_t> get_temporary_buffer( ptrdiff_t _Count ); 参数_Count 将哪内存请求的元素的最大数目。返回值第一个元素是指向内存分配,因此,第二个元素提供的缓冲区的大小,指示元素的大量它所能存储的 pair。备注函数...
Allocates temporary storage for a sequence of elements that does not exceed a specified number of elements.复制 template<class Type> pair<Type *, ptrdiff_t> get_temporary_buffer( ptrdiff_t _Count ); Parameters_Count The maximum number of elements requested for which memory is to be allocated...