diff --git a/src/Statement.cc b/src/Statement.cc index f21c26ca0b1b5700bda958d5101f0dc847649914..2a78af589c9470394b8eb5bdc8df3d2a449651e9 100644 --- a/src/Statement.cc +++ b/src/Statement.cc @@ -185,82 +185,84 @@ void OptionsList::writeOutputCommon(ostream &output, const string &option_group) const { for (const auto &[name, val] : options) - auto name1 = name; - std::visit([&]<class T>(const T &v) { - if constexpr(is_same_v<T, SymbolListVal>) - v.writeOutput(option_group + "." + name1, output); - else - { - output << option_group << "." << name1 << " = "; - if constexpr(is_same_v<T, NumVal> || is_same_v<T, DateVal>) - output << v; - else if constexpr(is_same_v<T, pair<string, string>>) - output << '[' << v.first << "; " << v.second << ']'; - else if constexpr(is_same_v<T, StringVal>) - output << "'" << v << "'"; - else if constexpr(is_same_v<T, vector<int>>) - { - if (v.size() > 1) + auto name1 = name; + std::visit([&]<class T>(const T &v) + { + if constexpr(is_same_v<T, SymbolListVal>) + v.writeOutput(option_group + "." + name1, output); + else + { + output << option_group << "." << name1 << " = "; + if constexpr(is_same_v<T, NumVal> || is_same_v<T, DateVal>) + output << v; + else if constexpr(is_same_v<T, pair<string, string>>) + output << '[' << v.first << "; " << v.second << ']'; + else if constexpr(is_same_v<T, StringVal>) + output << "'" << v << "'"; + else if constexpr(is_same_v<T, vector<int>>) + { + if (v.size() > 1) + { + output << '['; + for (int it : v) + output << it << ";"; + output << ']'; + } + else + output << v.front(); + } + else if constexpr(is_same_v<T, VecStrVal>) { - output << '['; - for (int it : v) - output << it << ";"; - output << ']'; - } - else - output << v.front(); - } - else if constexpr(is_same_v<T, VecStrVal>) - { - if (v.size() > 1) + if (v.size() > 1) + { + output << '{'; + for (const auto &it : v) + output << "'" << it << "';"; + output << '}'; + } + else + output << v.front(); + } + else if constexpr(is_same_v<T, VecCellStrVal>) { - output << '{'; - for (const auto &it : v) - output << "'" << it << "';"; - output << '}'; - } - else - output << v.front(); - } - else if constexpr(is_same_v<T, VecCellStrVal>) - { - /* VecCellStrVal should ideally be merged into VecStrVal. - only difference is treatment of v.size==1, where VecStrVal - does not add quotes and curly brackets, i.e. allows for type conversion of - '2' into the number 2 */ - output << '{'; - for (const auto &it : v) - output << "'" << it << "';"; - output << '}'; - } - else if constexpr(is_same_v<T, VecValueVal>) - { - /* For historical reason, those vectors are output as row vectors (contrary - to vectors of integers which are output as column vectors) */ - output << '['; - for (const auto &it : v) - output << it << ','; - output << ']'; - } - else if constexpr(is_same_v<T, vector<vector<string>>>) - { - // Same remark as for VecValueVal - output << '{'; - for (const auto &v2 : v) + /* VecCellStrVal should ideally be merged into VecStrVal. + only difference is treatment of v.size==1, where VecStrVal + does not add quotes and curly brackets, i.e. allows for type conversion of + '2' into the number 2 */ + output << '{'; + for (const auto &it : v) + output << "'" << it << "';"; + output << '}'; + } + else if constexpr(is_same_v<T, VecValueVal>) { - output << '['; - for (const auto &it : v2) - output << it << ','; - output << "], "; - } - output << '}'; - } - else - static_assert(always_false_v<T>, "Non-exhaustive visitor!"); - output << ";" << endl; - } - }, val); + /* For historical reason, those vectors are output as row vectors (contrary + to vectors of integers which are output as column vectors) */ + output << '['; + for (const auto &it : v) + output << it << ','; + output << ']'; + } + else if constexpr(is_same_v<T, vector<vector<string>>>) + { + // Same remark as for VecValueVal + output << '{'; + for (const auto &v2 : v) + { + output << '['; + for (const auto &it : v2) + output << it << ','; + output << "], "; + } + output << '}'; + } + else + static_assert(always_false_v<T>, "Non-exhaustive visitor!"); + output << ";" << endl; + } + }, val); + } } void