Arkadash-im, these new syntaxes are too much for some folks like me!!! Can you simplify it in something like FORTRAN-77????
Explanation given below for each line. Google for any terms you are not familiar with.
// Create Pak Army object
PakArmy army;
// Create PAF object
PAF airforce;
// Create Pak Navy object
PN navy;
// Pass individual forces to an overall military object, using the C++ uniform initializer syntax.
Military mil{army, airforce, navy};
// Create an empty vector of Houthi targets
std::vector<HouthiTarget> houthis;
// Retrieve list of Houthi targets
PopulateTargets(houthis);
// std::all_of takes an iterator range in the first two parameters, and for each element applies
// the functor passed in the third parameter. In this case, the functor is a C++14 generic
// lambda whose single parameter is a forwarding reference.
// If the functor returns true for all elements in the range, then std::all_of will also return true
// otherwise it will return false.
if (std::all_of(houthis.begin(), houthis.end(),
[&mil] (auto&& target)
{
// The forwarding reference allows us to utilize move semantics when passing the target
// to the destroy method of mil object. This passes ownership of the targets to the mil
// object. The destroy method will return true if target is successfully destroyed. Remember
// we have passed all the forces to mil, so internally, destroy can use them as it likes.
return mil.destroy(std::move(target));
})
{
// If all targets successfully destroyed, upgrade the military.
mil.upgrade();
}