Replaced for-loop with std::transform.
This commit is contained in:
parent
adead24ba2
commit
c8b123da05
|
@ -21,6 +21,8 @@
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <iterator>
|
||||||
#include <mastodon-cpp/mastodon-cpp.hpp>
|
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||||
#include <boost/property_tree/ptree.hpp>
|
#include <boost/property_tree/ptree.hpp>
|
||||||
#include <boost/property_tree/json_parser.hpp>
|
#include <boost/property_tree/json_parser.hpp>
|
||||||
|
@ -73,12 +75,13 @@ void read_config(pt::ptree &config, string &instance, string &access_token)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void populate_vector(const pt::ptree &ingredients, const string &node, std::vector<string> &vector)
|
void populate_vector(const pt::ptree &ingredients, const string &node,
|
||||||
|
std::vector<string> &vector)
|
||||||
{
|
{
|
||||||
for (const pt::ptree::value_type &value : ingredients.get_child(node))
|
const pt::ptree childs = ingredients.get_child(node);
|
||||||
{
|
std::transform(childs.begin(), childs.end(), std::back_inserter(vector),
|
||||||
vector.push_back(value.second.data());
|
[](const pt::ptree::value_type &value)
|
||||||
}
|
{ return value.second.data(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
string get_ingredient(std::vector<string> &vector)
|
string get_ingredient(std::vector<string> &vector)
|
||||||
|
|
Loading…
Reference in New Issue