I have a situation where I need to copy an array of pointers stored in a class to another class. Following the second answer to this question, I have created this reproducible example of what I am trying to do in my actual project.
#include <iostream>
#include <iterator>
struct A{};
class Something
{
public:
static constexpr int nItems = 5;
A* pA[nItems];
};
class AnotherThing
{
public:
A* pACopy[Something::nItems];
void CopyPointers(const A* pA[Something::nItems])
{
std::copy(std::begin(pA), std::end(pA), std::begin(pACopy));
}
};
int main()
{
Something something;
AnotherThing anotherThing;
anotherThing.CopyPointers(something.pA);
}
Error is in line std::copy(std::begin(pA), std::end(pA), std::begin(pACopy));
and the error is
no instance of overload function "std::begin" matches the argument list
. And its the same for std::end
as well.