I'm trying to make the following code to work
auto createMyArray = []() {
float foo[] = {0.0f, 1.5f, 2.0f};
return foo;
};
auto myArray = createMyArray();
std::vector<float> myVector;
// fatal error: no matching function for call to 'begin'
myVector.insert(myVector.end(), std::begin(myArray), std::end(myArray));
The issue is that createMyArray returns a pointer to the array and I'm not sure if it will be a good idea to try dereference it.
Also I'm getting the following warning
warning: address of stack memory associated with local variable 'foo' returned [-Wreturn-stack-address]
return foo;
Which has sense because I'm not using new to create the array since I want to avoid heap allocations.