What am I doing wrong? In the following templated functions, I'm trying to convert all my CopyMemory functions to std::copy functions.
I'm not sure what I'm doing wrong as they don't work as they should with the std::copy but instead, they work with memcpy and CopyMemory. I'm only doing it to understand how to use std::copy on arrays and pointers rather than plain iterators.
template<typename T>
void S(unsigned char* &Destination, const T &Source)
{
//CopyMemory(Destination, &Source, sizeof(T));
std::copy(&Source, &Source + sizeof(T), Destination); //Fails..
Destination += sizeof(T);
}
template<typename T>
void D(T* &Destination, unsigned char* Source, size_t Size)
{
CopyMemory(Destination, Source, Size);
Source += sizeof(T);
}
template<typename T>
void D(T &Destination, unsigned char* Source, size_t Size)
{
CopyMemory(&Destination, Source, Size);
Source += sizeof(T);
}
I've also figured that I could do the following to convert iterators to pointers:
std::string Foo = "fdsgsdgs";
std::string::iterator it = Foo.begin();
unsigned char* pt = &(*it);
How would I convert pointers to iterators then? :S