From: Wolfgang Bangerth Date: Sat, 2 May 2020 18:08:49 +0000 (-0600) Subject: Use std_cxx20::ranges::iota_range. X-Git-Tag: v9.2.0-rc1~57^2~5 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c05e851af48d48a1a797e7ff80db70162d4c8d6e;p=dealii.git Use std_cxx20::ranges::iota_range. --- diff --git a/examples/step-69/step-69.cc b/examples/step-69/step-69.cc index a1906f05dc..e530648acf 100644 --- a/examples/step-69/step-69.cc +++ b/examples/step-69/step-69.cc @@ -78,9 +78,9 @@ #include #include -// The last two boost header files are for creating custom iterator ranges +// The last two header files are for creating custom iterator ranges // over integer intervals. -#include +#include #include // For std::isnan, std::isinf, std::ifstream, std::async, and std::future @@ -1225,7 +1225,8 @@ namespace Step69 // defined by the indices.begin() and // indices.end() iterators into subranges (we want to be // able to read any entry in those subranges with constant complexity). - // In order to provide such iterators we resort to boost::irange. + // In order to provide such iterators we resort to + // std_cxx20::ranges::iota_view. // // The bulk of the following piece of code is spent defining // the "worker" on_subranges: i.e. the operation applied at @@ -1252,10 +1253,10 @@ namespace Step69 // // We have one more difficulty to overcome: In order to implement the // on_subranges lambda we need to name the iterator type - // of the object returned by boost::irange%std_cxx20::ranges::iota_view%(). This is unfortunately a very convoluted name exposing - // implementation details about boost::irange. For this - // reason we resort to the std_cxx20::ranges::iota_view. + // For this reason we resort to the decltype // specifier, a C++11 feature that returns the type of an entity, or // expression. @@ -1263,12 +1264,14 @@ namespace Step69 TimerOutput::Scope scope(computing_timer, "offline_data - compute |c_ij|, and n_ij"); - const auto indices = boost::irange(0, n_locally_relevant); + const std_cxx20::ranges::iota_view indices( + 0, n_locally_relevant); const auto on_subranges = // - [&](typename decltype(indices)::iterator i1, - const typename decltype(indices)::iterator i2) { - for (const auto row_index : boost::make_iterator_range(i1, i2)) + [&](std_cxx20::ranges::iota_view::iterator i1, + const std_cxx20::ranges::iota_view::iterator i2) { + for (const auto row_index : + std_cxx20::ranges::iota_view(*i1, *i2)) { // First column-loop: we compute and store the entries of the // matrix norm_matrix and write normalized entries into the @@ -1870,9 +1873,10 @@ namespace Step69 const auto &n_locally_owned = offline_data->n_locally_owned; const auto &n_locally_relevant = offline_data->n_locally_relevant; - const auto indices_owned = boost::irange(0, n_locally_owned); - const auto indices_relevant = - boost::irange(0, n_locally_relevant); + const std_cxx20::ranges::iota_view indices_owned( + 0, n_locally_owned); + const std_cxx20::ranges::iota_view indices_relevant( + 0, n_locally_relevant); const auto &sparsity = offline_data->sparsity_pattern; @@ -1926,9 +1930,10 @@ namespace Step69 "time_stepping - 1 compute d_ij"); const auto on_subranges = // - [&](typename decltype(indices_relevant)::iterator i1, - const typename decltype(indices_relevant)::iterator i2) { - for (const auto i : boost::make_iterator_range(i1, i2)) + [&](std_cxx20::ranges::iota_view::iterator i1, + const std_cxx20::ranges::iota_view::iterator i2) { + for (const auto i : + std_cxx20::ranges::iota_view(*i1, *i2)) { const auto U_i = gather(U, i); @@ -2021,11 +2026,12 @@ namespace Step69 // locally. const auto on_subranges = // - [&](typename decltype(indices_relevant)::iterator i1, - const typename decltype(indices_relevant)::iterator i2) { + [&](std_cxx20::ranges::iota_view::iterator i1, + const std_cxx20::ranges::iota_view::iterator i2) { double tau_max_on_subrange = std::numeric_limits::infinity(); - for (const auto i : boost::make_iterator_range(i1, i2)) + for (const auto i : + std_cxx20::ranges::iota_view(*i1, *i2)) { double d_sum = 0.; @@ -2344,7 +2350,8 @@ namespace Step69 const auto &boundary_normal_map = offline_data->boundary_normal_map; const auto &n_locally_owned = offline_data->n_locally_owned; - const auto indices = boost::irange(0, n_locally_owned); + const auto indices = + std_cxx20::ranges::iota_view(0, n_locally_owned); // We define the r_i_max and r_i_min in the current MPI process as // atomic doubles in order to avoid race conditions between threads: diff --git a/include/deal.II/base/geometry_info.h b/include/deal.II/base/geometry_info.h index 1f15383965..d8ea7c5e4e 100644 --- a/include/deal.II/base/geometry_info.h +++ b/include/deal.II/base/geometry_info.h @@ -21,8 +21,7 @@ #include #include - -#include +#include #include #include @@ -1947,7 +1946,7 @@ struct GeometryInfo * taking on all valid indices for faces (zero and one in 1d, zero * through three in 2d, and zero through 5 in 3d). */ - static boost::integer_range + static std_cxx20::ranges::iota_view face_indices(); /** @@ -1978,7 +1977,7 @@ struct GeometryInfo * Here, we are looping over all vertices of all cells, with `vertex_index` * taking on all valid indices. */ - static boost::integer_range + static std_cxx20::ranges::iota_view vertex_indices(); /** @@ -2833,19 +2832,19 @@ GeometryInfo<0>::vertex_indices() template -inline boost::integer_range +inline std_cxx20::ranges::iota_view GeometryInfo::face_indices() { - return boost::irange(0U, faces_per_cell); + return std_cxx20::ranges::iota_view(0U, faces_per_cell); } template -inline boost::integer_range +inline std_cxx20::ranges::iota_view GeometryInfo::vertex_indices() { - return boost::irange(0U, vertices_per_cell); + return std_cxx20::ranges::iota_view(0U, vertices_per_cell); } diff --git a/include/deal.II/fe/fe_values.h b/include/deal.II/fe/fe_values.h index 452f4a2f43..59aa92b46c 100644 --- a/include/deal.II/fe/fe_values.h +++ b/include/deal.II/fe/fe_values.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -39,8 +40,6 @@ #include -#include - #include #include #include @@ -3031,7 +3030,7 @@ public: * `q_point` taking on all valid indices for quadrature points, as defined * by the quadrature rule passed to `fe_values`. */ - boost::integer_range + std_cxx20::ranges::iota_view quadrature_point_indices() const; /** @@ -5562,10 +5561,10 @@ FEValuesBase::dof_indices_ending_at( template -inline boost::integer_range +inline std_cxx20::ranges::iota_view FEValuesBase::quadrature_point_indices() const { - return boost::irange(0U, n_quadrature_points); + return std_cxx20::ranges::iota_view(0U, n_quadrature_points); }