#include <deal.II/base/config.h>
#include <deal.II/base/exceptions.h>
+#include <deal.II/base/std_cxx17/variant.h>
DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
#include <boost/serialization/map.hpp>
#include <boost/serialization/split_member.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/vector.hpp>
-#include <boost/variant.hpp>
DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
#include <fstream>
/**
* A <tt>TableEntry</tt> stores the value of a table entry. It can either be
* of type int, unsigned int, std::uint64_t, double or std::string. In
- * essence, this structure is the same as <code>boost::variant@<int,unsigned
- * int,std::uint64_t,double,std::string@></code> but we wrap this object in a
+ * essence, this structure is the same as `std::variant<int,unsigned
+ * int,std::uint64_t,double,std::string>` but we wrap this object in a
* structure for which we can write a function that can serialize it. This is
- * also why the function is not in fact of type boost::any.
+ * also why the function is not in fact of type std::any.
*/
struct TableEntry
{
* Abbreviation for the data type stored by this object.
*/
using value_type =
- boost::variant<int, unsigned int, std::uint64_t, double, std::string>;
+ std_cxx17::variant<int, unsigned int, std::uint64_t, double, std::string>;
/**
* Stored value.
{
// we don't quite know the data type in 'value', but
// it must be one of the ones in the type list of the
- // boost::variant. so if T is not in the list, or if
+ // std_cxx17::variant. so if T is not in the list, or if
// the data stored in the TableEntry is not of type
// T, then we will get an exception that we can
// catch and produce an error message
try
{
- return boost::get<T>(value);
+ return std_cxx17::get<T>(value);
}
catch (...)
{
{
// we don't quite know the data type in 'value', but
// it must be one of the ones in the type list of the
- // boost::variant. Go through this list and return
+ // std_cxx17::variant. Go through this list and return
// the value if this happens to be a number
//
// first try with int
try
{
- return boost::get<int>(value);
+ return std_cxx17::get<int>(value);
}
catch (...)
{}
// ... then with unsigned int...
try
{
- return boost::get<unsigned int>(value);
+ return std_cxx17::get<unsigned int>(value);
}
catch (...)
{}
// ... then with std::uint64_t...
try
{
- return boost::get<std::uint64_t>(value);
+ return std_cxx17::get<std::uint64_t>(value);
}
catch (...)
{}
// ...and finally with double precision:
try
{
- return boost::get<double>(value);
+ return std_cxx17::get<double>(value);
}
catch (...)
{
}
+#ifndef DEAL_II_HAVE_CXX17
namespace Local
{
// see which type we can cast to, then use this type to create
}
};
} // namespace Local
+#endif
TableEntry
TableEntry::get_default_constructed_copy() const
{
TableEntry new_entry = *this;
+#ifndef DEAL_II_HAVE_CXX17
boost::apply_visitor(Local::GetDefaultValue(), new_entry.value);
+#else
+ // 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);
+#endif
return new_entry;
}