#include
#include // Include for file stream operations
#include "toml.hpp"
#include
#include
#include
using namespace std;
int main(int argc, char* argv[])
{
toml::table tbl;
tbl = toml::parse(file); // file is some string that I get from user input. This part works for sure.
...
auto dontVary_array = tbl["Calculator_parameters"]["dontVary"];
vector dontVary;
if (toml::array* arr = dontVary_array.as_array()) {
arr->for_each([&dontVary](auto&& el)
{
if (const auto* int_elem = el.as_integer())
dontVary.push_back((int)(*int_elem)); //Type mismatch somewhere here???
else
cerr
Подробнее здесь: [url]https://stackoverflow.com/questions/78266480/toml-conversion-to-vectorintc[/url]
Представьте, что у меня есть .toml, содержащий это: [code][Calculator_parameters] dontVary = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] [/code] Как мне преобразовать это в вектор для отправки через интерфейс MPI с помощью toml++ (https://marzer.github.io/tomlplusplus/index.html)? Я пробовал что-то вроде: [code]#include #include // Include for file stream operations #include "toml.hpp" #include #include #include using namespace std;
int main(int argc, char* argv[]) { toml::table tbl; tbl = toml::parse(file); // file is some string that I get from user input. This part works for sure. ... auto dontVary_array = tbl["Calculator_parameters"]["dontVary"]; vector dontVary; if (toml::array* arr = dontVary_array.as_array()) { arr->for_each([&dontVary](auto&& el) { if (const auto* int_elem = el.as_integer()) dontVary.push_back((int)(*int_elem)); //Type mismatch somewhere here??? else cerr