From: Matthias Maier Date: Fri, 15 Jun 2018 23:54:28 +0000 (-0500) Subject: step-7: Use std::array instead of C-style array X-Git-Tag: v9.1.0-rc1~701^2~8 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13c083f176c8cd5f1f5e89686afe2737497b1246;p=dealii.git step-7: Use std::array instead of C-style array --- diff --git a/examples/step-7/step-7.cc b/examples/step-7/step-7.cc index b12af95c58..49202e94a5 100644 --- a/examples/step-7/step-7.cc +++ b/examples/step-7/step-7.cc @@ -64,6 +64,7 @@ // the same file as the FEValues class: #include +#include #include #include @@ -98,9 +99,9 @@ namespace Step7 class SolutionBase { protected: - static const unsigned int n_source_centers = 3; - static const Point source_centers[n_source_centers]; - static const double width; + static const unsigned int n_source_centers = 3; + static const std::array, n_source_centers> source_centers; + static const double width; }; @@ -123,16 +124,18 @@ namespace Step7 // it doesn't have to generate the variable from a template by substituting // dim, but can immediately use the following definition: template <> - const Point<1> - SolutionBase<1>::source_centers[SolutionBase<1>::n_source_centers] = - {Point<1>(-1.0 / 3.0), Point<1>(0.0), Point<1>(+1.0 / 3.0)}; + const std::array, SolutionBase<1>::n_source_centers> + SolutionBase<1>::source_centers = {Point<1>(-1.0 / 3.0), + Point<1>(0.0), + Point<1>(+1.0 / 3.0)}; // Likewise, we can provide an explicit specialization for // dim=2. We place the centers for the 2d case as follows: template <> - const Point<2> - SolutionBase<2>::source_centers[SolutionBase<2>::n_source_centers] = - {Point<2>(-0.5, +0.5), Point<2>(-0.5, -0.5), Point<2>(+0.5, -0.5)}; + const std::array, SolutionBase<2>::n_source_centers> + SolutionBase<2>::source_centers = {Point<2>(-0.5, +0.5), + Point<2>(-0.5, -0.5), + Point<2>(+0.5, -0.5)}; // There remains to assign a value to the half-width of the exponentials. We // would like to use the same value for all dimensions. In this case, we