#ifndef DEAL_II_HAVE_CXX17
using boost::get;
using boost::variant;
+
+ template <typename T, typename... Ts>
+ bool
+ holds_alternative(const boost::variant<Ts...> &v) noexcept
+ {
+ return boost::get<T>(&v) != nullptr;
+ }
#else
using std::get;
+ using std::holds_alternative;
using std::variant;
#endif
} // namespace std_cxx17
// write first an identifier for the kind
// of data stored and then the actual
// data, in its correct data type
- if (const int *p = std_cxx17::get<int>(&value))
+ if (std_cxx17::holds_alternative<int>(value))
{
- char c = 'i';
- ar &c &*p;
+ const int p = std_cxx17::get<int>(value);
+ char c = 'i';
+ ar &c &p;
}
- else if (const unsigned int *p = std_cxx17::get<unsigned int>(&value))
+ else if (std_cxx17::holds_alternative<unsigned int>(value))
{
- char c = 'u';
- ar &c &*p;
+ const unsigned int p = std_cxx17::get<unsigned int>(value);
+ char c = 'u';
+ ar &c &p;
}
- else if (const double *p = std_cxx17::get<double>(&value))
+ else if (std_cxx17::holds_alternative<double>(value))
{
- char c = 'd';
- ar &c &*p;
+ const double p = std_cxx17::get<double>(value);
+ char c = 'd';
+ ar &c &p;
}
- else if (const std::string *p = std_cxx17::get<std::string>(&value))
+ else if (std_cxx17::holds_alternative<std::string>(value))
{
- char c = 's';
- ar &c &*p;
+ const std::string p = std_cxx17::get<std::string>(value);
+ char c = 's';
+ ar &c &p;
}
- else if (const std::uint64_t *p = std_cxx17::get<std::uint64_t>(&value))
+ else if (std_cxx17::holds_alternative<std::uint64_t>(value))
{
- char c = 'l';
- ar &c &*p;
+ const std::uint64_t p = std_cxx17::get<std::uint64_t>(value);
+ char c = 'l';
+ ar &c &p;
}
else
Assert(false, ExcInternalError());
else
ss.setf(std::ios::fixed, std::ios::floatfield);
+#ifdef DEAL_II_HAVE_CXX17
+ std::visit([&ss](auto &v) { ss << v; }, value);
+#else
ss << value;
+#endif
cached_value = ss.str();
if (cached_value.size() == 0)
// Let std::visit figure out which data type is actually stored,
// and then set the object so stored to a default-constructed
// one.
- std::visit([](auto &arg) { arg = decltype(arg)(); }, new_entry.value);
+ std::visit([](
+ auto &arg) { arg = std::remove_reference_t<decltype(arg)>(); },
+ new_entry.value);
#endif
return new_entry;
else
out.setf(std::ios::fixed, std::ios::floatfield);
+#ifdef DEAL_II_HAVE_CXX17
+ std::visit([&out](auto &v) { out << v; }, column.entries[i].value);
+#else
out << column.entries[i].value;
+#endif
if (j < n_cols - 1)
out << " & ";