Remix.run Logo
voidUpdate 3 hours ago

> "An interesting question you may ask in C++ is: “How would you declare a function that takes a blob of memory as input?”"

> "Now, suppose that you want to pass to this function a custom structure, like this:"

You would create another function that actually works based off that structure, rather than using your first function which operates on a set of bytes in memory. That way it's readable, like they want, and type-safe

3 hours ago | parent | next [-]
[deleted]
trumpdong 3 hours ago | parent | prev [-]

I find this to be a snarky non-answer. You really think everyone should write their own memcpy for every POD type they want to memcpy?

mfost 2 hours ago | parent [-]

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.