Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using memcpy to copy a vector #56

Open
paroj opened this issue Oct 23, 2012 · 1 comment
Open

Using memcpy to copy a vector #56

paroj opened this issue Oct 23, 2012 · 1 comment

Comments

@paroj
Copy link
Owner

paroj commented Oct 23, 2012

Originally reported by: Anonymous


In http://www.arcsynthesis.org/gltut/Positioning/Tutorial%2003.html, Example 3.2,
this:
#!c++
memcpy(&fNewData[0], vertexPositions, sizeof(vertexPositions));

should really be this:
#!c++
std::copy(vertexPositions, vertexPositions+sizeof(vertexPositions), fNewData.begin());

or even better:
#!c++
std::vector fNewData(vertexPositions, vertexPositions+sizeof(vertexPositions));

(std::begin / std::end could be used, but I doubt the tutorials should require C++11 compliance)


@paroj
Copy link
Owner Author

paroj commented Oct 24, 2012

Original comment by Jason McKesson (Bitbucket: alfonse, GitHub: alfonse):


I'll consider it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant