So.. How can we call something like
memcpy(dataCopy, data, length); to copy abstract data T?
Or if abstract T is not safe lets say we know that T is a POD (plain old data, basically a C struct) – is it possible to copy it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Do you mean working for some arbitrary C++ type
T? Unless you know thatTis a POD (plain old data, basically a C struct) type, it is not safe to copy objects of typeTwithmemcpy. That would preventT‘s copy constructor from running, for example, which might lead to an incorrect copy (trying tomemcpyanstd::vectorwould not copy the data buffer, for example).