From 7f5d66eab8fd6922350e62ff61adce5d0b06c683 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Sat, 1 Jul 2023 14:23:37 -0400 Subject: [PATCH] Clean up DEAL_II_HAVE_CXX17 --- include/deal.II/base/std_cxx17/algorithm.h | 10 +------ include/deal.II/base/std_cxx17/optional.h | 10 +------ include/deal.II/base/std_cxx17/variant.h | 18 +------------ include/deal.II/base/thread_local_storage.h | 4 --- source/base/data_out_base.cc | 16 ----------- source/base/table_handler.cc | 30 --------------------- source/opencascade/utilities.cc | 9 ++----- tests/data_out/patches.h | 11 -------- 8 files changed, 5 insertions(+), 103 deletions(-) diff --git a/include/deal.II/base/std_cxx17/algorithm.h b/include/deal.II/base/std_cxx17/algorithm.h index b4437bdc46..d8404b88a6 100644 --- a/include/deal.II/base/std_cxx17/algorithm.h +++ b/include/deal.II/base/std_cxx17/algorithm.h @@ -17,20 +17,12 @@ #include -#ifdef DEAL_II_HAVE_CXX17 -# include -#else -# include -#endif +#include DEAL_II_NAMESPACE_OPEN namespace std_cxx17 { -#ifndef DEAL_II_HAVE_CXX17 - using boost::algorithm::clamp; -#else using std::clamp; -#endif } // namespace std_cxx17 DEAL_II_NAMESPACE_CLOSE diff --git a/include/deal.II/base/std_cxx17/optional.h b/include/deal.II/base/std_cxx17/optional.h index 284f5f4918..4d6cc23f2d 100644 --- a/include/deal.II/base/std_cxx17/optional.h +++ b/include/deal.II/base/std_cxx17/optional.h @@ -17,20 +17,12 @@ #include -#ifdef DEAL_II_HAVE_CXX17 -# include -#else -# include -#endif +#include DEAL_II_NAMESPACE_OPEN namespace std_cxx17 { -#ifndef DEAL_II_HAVE_CXX17 - using boost::optional; -#else using std::optional; -#endif } // namespace std_cxx17 DEAL_II_NAMESPACE_CLOSE diff --git a/include/deal.II/base/std_cxx17/variant.h b/include/deal.II/base/std_cxx17/variant.h index 146f0e3223..84cc794db4 100644 --- a/include/deal.II/base/std_cxx17/variant.h +++ b/include/deal.II/base/std_cxx17/variant.h @@ -17,30 +17,14 @@ #include -#ifdef DEAL_II_HAVE_CXX17 -# include -#else -# include -#endif +#include DEAL_II_NAMESPACE_OPEN namespace std_cxx17 { -#ifndef DEAL_II_HAVE_CXX17 - using boost::get; - using boost::variant; - - template - bool - holds_alternative(const boost::variant &v) noexcept - { - return boost::get(&v) != nullptr; - } -#else using std::get; using std::holds_alternative; using std::variant; -#endif } // namespace std_cxx17 DEAL_II_NAMESPACE_CLOSE diff --git a/include/deal.II/base/thread_local_storage.h b/include/deal.II/base/thread_local_storage.h index 4407c55627..05f637ee56 100644 --- a/include/deal.II/base/thread_local_storage.h +++ b/include/deal.II/base/thread_local_storage.h @@ -251,11 +251,7 @@ namespace Threads * readers-writer lock * (https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock). */ -# ifdef DEAL_II_HAVE_CXX17 mutable std::shared_mutex insertion_mutex; -# else - mutable std::shared_timed_mutex insertion_mutex; -# endif /** * An exemplar for creating a new (thread specific) copy. diff --git a/source/base/data_out_base.cc b/source/base/data_out_base.cc index dc1ba232a7..adc1bac0f4 100644 --- a/source/base/data_out_base.cc +++ b/source/base/data_out_base.cc @@ -9743,16 +9743,8 @@ namespace DataOutBase } // First import what kind of reference cell we are looking at: -#ifdef DEAL_II_HAVE_CXX17 if constexpr (dim > 0) in >> patch.reference_cell; -#else - // If we can't use 'if constexpr', work around the fact that we can't - // write to a 'const' variable by using a const_cast that is a no-op - // whenever the code is actually executed - if (dim > 0) - in >> const_cast(patch.reference_cell); -#endif // then read all the data that is in this patch for (const unsigned int i : patch.reference_cell.vertex_indices()) @@ -9767,16 +9759,8 @@ namespace DataOutBase // in dim==1, this is a const variable equal to one that can't be changed. unsigned int n_subdivisions; in >> n_subdivisions; -#ifdef DEAL_II_HAVE_CXX17 if constexpr (dim > 1) patch.n_subdivisions = n_subdivisions; -#else - // If we can't use 'if constexpr', work around the fact that we can't - // write to a 'const' variable by using a const_cast that is a no-op - // whenever the code is actually executed - if (dim > 1) - const_cast(patch.n_subdivisions) = n_subdivisions; -#endif in >> patch.points_are_available; diff --git a/source/base/table_handler.cc b/source/base/table_handler.cc index b076ee1bf9..61f2b529dd 100644 --- a/source/base/table_handler.cc +++ b/source/base/table_handler.cc @@ -91,11 +91,7 @@ namespace internal 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) @@ -108,38 +104,16 @@ namespace internal return cached_value; } - -#ifndef DEAL_II_HAVE_CXX17 - namespace Local - { - // see which type we can cast to, then use this type to create - // a default constructed object - struct SetValueToDefault : public boost::static_visitor<> - { - template - void - operator()(T &operand) const - { - operand = T(); - } - }; - } // namespace Local -#endif - TableEntry TableEntry::get_default_constructed_copy() const { TableEntry new_entry = *this; -#ifndef DEAL_II_HAVE_CXX17 - boost::apply_visitor(Local::SetValueToDefault(), 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 = std::remove_reference_t(); }, new_entry.value); -#endif return new_entry; } @@ -728,11 +702,7 @@ TableHandler::write_tex(std::ostream &out, const bool with_header) const 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 << " & "; diff --git a/source/opencascade/utilities.cc b/source/opencascade/utilities.cc index facee29430..5ec92e4a55 100644 --- a/source/opencascade/utilities.cc +++ b/source/opencascade/utilities.cc @@ -710,13 +710,8 @@ namespace OpenCASCADE double minDistance = 1e7; gp_Pnt tmp_proj(0.0, 0.0, 0.0); -# ifdef DEAL_II_HAVE_CXX17 - [[maybe_unused]] unsigned int counter = 0; -# else - unsigned int counter = 0; - (void)counter; -# endif - unsigned int face_counter = 0; + [[maybe_unused]] unsigned int counter = 0; + unsigned int face_counter = 0; TopoDS_Shape out_shape; double u = 0; diff --git a/tests/data_out/patches.h b/tests/data_out/patches.h index a3e1cc5786..2f23985677 100644 --- a/tests/data_out/patches.h +++ b/tests/data_out/patches.h @@ -34,22 +34,11 @@ create_patches(std::vector> &patches) const unsigned int nsub = p + 1; const unsigned int nsubp = nsub + 1; -#ifdef DEAL_II_HAVE_CXX17 if constexpr (dim > 0) patch.n_subdivisions = nsub; -#else - if (dim > 0) - const_cast(patch.n_subdivisions) = nsub; -#endif -#ifdef DEAL_II_HAVE_CXX17 if constexpr (dim > 0) patch.reference_cell = ReferenceCells::get_hypercube(); -#else - if (dim > 0) - const_cast(patch.reference_cell) = - ReferenceCells::get_hypercube(); -#endif for (const unsigned int v : GeometryInfo::vertex_indices()) for (unsigned int d = 0; d < spacedim; ++d) -- 2.39.5