在C ++中的memcpy等价物 [英] memcpy equivalent in C++
问题描述
我想知道C ++是否具有相当于
memcpy的类及其在C中可用的相关函数。
Hi,
I would like to know if C++ has a class equivalent to
memcpy and its associated functions available in C.
推荐答案
11月19日9:11 * am,mthread< rjk ... @ gmail.comwrote:
On Nov 19, 9:11*am, mthread <rjk...@gmail.comwrote:
* * * * * *我想知道C ++是否有一个类等于
memcpy及其相关函数可用于C.
* * * * * *I would like to know if C++ has a class equivalentto
memcpy and its associated functions available in C.
来自< algorithmheader的std :: copy()。 http://www.sgi.com/tech/stl/copy ..html
-
Max
It is std::copy() from <algorithmheader. http://www.sgi.com/tech/stl/copy..html
--
Max
2008-11- 19 10:11,mthread写道:
On 2008-11-19 10:11, mthread wrote:
我想知道C ++是否有类似于
的类
memcpy及其相关函数可用于C.
Hi,
I would like to know if C++ has a class equivalent to
memcpy and its associated functions available in C.
memcpy()也可以在C ++中使用,但是你应该只将它用于原始
数据,如果你在对象上使用它,你可能会得到令人讨厌的惊喜。对于
对象,你应该使用std :: copy()作为Max指出。
-
Erik Wikstr ?? m
memcpy() is also available in C++, but you should only use it for raw
data, if you use it on objects you might get nasty surprises. For
objects you should use std::copy() as Max pointed out.
--
Erik Wikstr??m
Maxim Yegorushkin写道:
Maxim Yegorushkin wrote:
11月19日上午9:11,mthread< rjk。 .. @ gmail.comwrote:
On Nov 19, 9:11 am, mthread <rjk...@gmail.comwrote:
>我想知道C ++是否有一个等同于
memcpy的类及其在C中可用的相关函数。
> I would like to know if C++ has a class equivalent to
memcpy and its associated functions available in C.
它是std :: copy()来自< algorithmheader。 http://www.sgi.com/tech/stl/copy。 html
std :: copy与memcpy不同。 std :: copy尊重C ++
对象的'复制语义,这可能比
memcpy支持的复杂得多。 OP可能需要std :: memcpy,来自< cstring>
标题。
我想知道std :: copy的流行实现是否委托给memcpy
用于具有普通复制构造函数的类型。
std::copy is not the same thing as memcpy. std::copy honors C++
objects'' copy semantics, which can be a lot more complicated than what
memcpy supports. The OP probably wants std::memcpy, from the <cstring>
header.
I wonder whether popular implementations of std::copy delegate to memcpy
for types with trivial copy constructors.
这篇关于在C ++中的memcpy等价物的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!