7 ms·
There's no need: there's std::copy already. Or maybe the idea was to create a typesafe template wrapper around the generic function which is also very common a
by mfost 3mo ago
There's no need: there's std::copy already.
Or maybe the idea was to create a typesafe template wrapper around the generic function which is also very common and really nice. No need to create one wrapper per type, a single template should work.
- adrian_b 3mo agoAnd how was std:copy implemented? Your answer is valid only for a programming language which assumes that the standard library is implemented in another language. C/C++ are supposed to be languages in which any program can be written, unlike languages like Java or Python.
- AnimalMuppet 3mo agoYes, C++ has those parts. You can use them to write something like std::copy. But use them, once, to write std::copy, and get that one implementation right (or have the library writers do it for you), and then use std::copy everywhere, rather than using void* everywhere. This makes your program much more type safe and less buggy, while still letting you write the parts where you really need to use the down-and-dirty stuff.
- pjmlp 3mo agoYou cannot implement modern C++ in pure C++ nowadays, as the standard library requires compiler intrisics, just like a language like Java.