Assuming you have this array:
Ausfaelle Ausfaelle_Line[]={
{ 1, 2, 0, "OUTSID", 1, "EXTERNAL CHECKS PAGE 3", 0, 1, "sim/cockpit2/annunciators/passenger_oxy_on", NULL },
{ 1, 2, 0, "OUTSID", 1, "EXTERNAL CHECKS PAGE 3", 0, 1, "sim/cockpit2/annunciators/passenger_oxy_on", NULL },
{ 1, 2, 0, "OUTSID", 1, "EXTERNAL CHECKS PAGE 3", 0, 1, "sim/cockpit2/annunciators/passenger_oxy_on", NULL },
}
If you want to add copies of each Ausfaelle to a list, you do:
std::list<Ausfaelle> points;
// Copy from beginning to end of Ausfaelle_Line, and push onto the back of the "points" list:
std::copy(std::begin(Ausfaelle_Line), std::end(Ausfaelle_Line), std::back_inserter(points));
If, instead, you want pointers to the Ausfaelle objects in Ausfaelle_Line (an important distinction), you can do:
std::list<Ausfaelle*> pointsPointers;
// Using std::transform here, because the source type is Ausfaelle, but the destination type is Ausfaelle*
std::transform(std::begin(Ausfaelle_Line), std::end(Ausfaelle_Line), std::back_inserter(pointsPointers),
[](Ausfaelle &thing) { return &thing; } // "convert" Ausfaelle& to Ausfaelle*
);
The distinction here is different. Are you wanting to work on copies of the objects in the original array? Or actually references to them?
Other questions you need to think about:
- what is the lifetime of this Ausfaelle data? If you're copying pointers to the objects into a list, you need to ensure the original objects are kept alive as long as you are using that list. Not a problem in the case when you have a static array you've copied from - but if they might come from other sources, you need to consider this
- Why are you using a list, and not a vector?
I might also note that the c++ containers support initializer lists, so you can do this directly:
std::list<Ausfaelle> Ausfaelle_Line = {
{ 1, 2, 0, "OUTSID", 1, "EXTERNAL CHECKS PAGE 3", 0, 1, "sim/cockpit2/annunciators/passenger_oxy_on", NULL },
{ 1, 2, 0, "OUTSID", 1, "EXTERNAL CHECKS PAGE 3", 0, 1, "sim/cockpit2/annunciators/passenger_oxy_on", NULL },
{ 1, 2, 0, "OUTSID", 1, "EXTERNAL CHECKS PAGE 3", 0, 1, "sim/cockpit2/annunciators/passenger_oxy_on", NULL },
};
... if that's what you want...