c++booststl

memcpy equivalent for skipping x bytes while copying (not just initial x bytes)?


I'm looking for an existing function similar to memcpy that can be told to copy x bytes and then skip y bytes, repeating until a specified amount has been copied.

Imagine a buffer with data: AABAAB (I've used characters, but the data I'm manipulating is not string data).

When applied to this buffer and told to copy 2 bytes and skip 1 byte, the destination buffer would contain: AAAA.

I haven't found anything looking through STL and Boost, but am hoping there's something in either that I've missed.

Or perhaps there's a clever (and not nasty) way of using more common functions to achieve the same thing.


Solution

  • There doesn't appear to be a direct equivalent of memcpy for doing what I wanted. Boost does seem to often some useful helper functions, but I ended up implementing a simple looping function to do the job as it seemed the most simple & appropriate solution.