From 34f54573c51aab03361de020cf90d99c61f34f6a Mon Sep 17 00:00:00 2001 From: David Wells Date: Sun, 13 Aug 2017 17:16:41 -0400 Subject: [PATCH] Deprecate types_are_equal. C++11 provides std::is_same, which has the same functionality. --- include/deal.II/base/aligned_vector.h | 2 +- include/deal.II/base/template_constraints.h | 12 ++++++-- .../deal.II/lac/constraint_matrix.templates.h | 6 ++-- include/deal.II/lac/full_matrix.templates.h | 28 +++++++++---------- include/deal.II/lac/precondition.h | 6 ++-- include/deal.II/lac/solver_cg.h | 4 +-- .../lac/sparse_decomposition.templates.h | 2 +- .../deal.II/lac/vector_operations_internal.h | 4 +-- include/deal.II/matrix_free/fe_evaluation.h | 4 +-- .../matrix_free/shape_info.templates.h | 4 +-- source/fe/fe_q_base.cc | 6 ++-- tests/lac/gmres_eigenvalues.cc | 2 +- tests/lac/gmres_reorthogonalize_01.cc | 2 +- tests/lac/gmres_reorthogonalize_03.cc | 2 +- tests/lac/la_vector_add_and_dot.cc | 2 +- tests/lac/vector_add_and_dot.cc | 2 +- tests/matrix_free/get_functions_multife.cc | 4 +-- tests/matrix_free/get_functions_multife2.cc | 4 +-- tests/matrix_free/parallel_multigrid.cc | 4 +-- tests/matrix_free/parallel_multigrid_02.cc | 4 +-- .../parallel_multigrid_adaptive_01.cc | 4 +-- .../parallel_multigrid_adaptive_02.cc | 4 +-- .../parallel_multigrid_adaptive_04.cc | 4 +-- 23 files changed, 61 insertions(+), 55 deletions(-) diff --git a/include/deal.II/base/aligned_vector.h b/include/deal.II/base/aligned_vector.h index 29b0933023..7b36302ff6 100644 --- a/include/deal.II/base/aligned_vector.h +++ b/include/deal.II/base/aligned_vector.h @@ -412,7 +412,7 @@ namespace internal // completely fill its memory and may lead to false positives in // e.g. valgrind if (std::is_trivial::value == true && - types_are_equal::value == false) + std::is_same::value == false) { const unsigned char zero [sizeof(T)] = {}; // cast element to (void*) to silence compiler warning for virtual diff --git a/include/deal.II/base/template_constraints.h b/include/deal.II/base/template_constraints.h index f98785b014..1ea8046798 100644 --- a/include/deal.II/base/template_constraints.h +++ b/include/deal.II/base/template_constraints.h @@ -283,7 +283,7 @@ namespace internal * @code * template * void Vector::some_operation () { - * if (types_are_equal::value == true) + * if (std::is_same::value == true) * call_some_blas_function_for_doubles; * else * do_it_by_hand; @@ -292,24 +292,30 @@ namespace internal * * This construct is made possible through the existence of a partial * specialization of the class for template arguments that are equal. + * + * @deprecated Use the standard library type trait std::is_same + * instead of this class. */ template struct types_are_equal { static const bool value = false; -}; +} DEAL_II_DEPRECATED; /** * Partial specialization of the general template for the case that both * template arguments are equal. See the documentation of the general template * for more information. + * + * @deprecated Use the standard library type trait std::is_same + * instead of this class. */ template struct types_are_equal { static const bool value = true; -}; +} DEAL_II_DEPRECATED; /** diff --git a/include/deal.II/lac/constraint_matrix.templates.h b/include/deal.II/lac/constraint_matrix.templates.h index e7588f4318..237a7728b5 100644 --- a/include/deal.II/lac/constraint_matrix.templates.h +++ b/include/deal.II/lac/constraint_matrix.templates.h @@ -2241,7 +2241,7 @@ ConstraintMatrix::distribute_local_to_global ( global_vector.size() == 0) ? false : true; typedef typename MatrixType::value_type number; const bool use_dealii_matrix = - types_are_equal >::value; + std::is_same >::value; AssertDimension (local_matrix.n(), local_dof_indices.size()); AssertDimension (local_matrix.m(), local_dof_indices.size()); @@ -2344,7 +2344,7 @@ ConstraintMatrix::distribute_local_to_global ( // add must be equal if we have a Trilinos or PETSc vector but do not have to // be if we have a deal.II native vector: one could further optimize this for // Vector, LinearAlgebra::distributed::vector, etc. - if (types_are_equal::value) + if (std::is_same::value) { global_vector.add(vector_indices, *reinterpret_cast *>(&vector_values)); @@ -2382,7 +2382,7 @@ distribute_local_to_global (const FullMatrix & global_vector.size() == 0) ? false : true; typedef typename MatrixType::value_type number; const bool use_dealii_matrix = - types_are_equal >::value; + std::is_same >::value; AssertDimension (local_matrix.n(), local_dof_indices.size()); AssertDimension (local_matrix.m(), local_dof_indices.size()); diff --git a/include/deal.II/lac/full_matrix.templates.h b/include/deal.II/lac/full_matrix.templates.h index 2dd9ded9ae..d225677f77 100644 --- a/include/deal.II/lac/full_matrix.templates.h +++ b/include/deal.II/lac/full_matrix.templates.h @@ -527,11 +527,11 @@ void FullMatrix::mmult (FullMatrix &dst, // works for us (it is usually not efficient to use BLAS for very small // matrices): #ifdef DEAL_II_WITH_LAPACK - if ((types_are_equal::value + if ((std::is_same::value || - types_are_equal::value) + std::is_same::value) && - types_are_equal::value) + std::is_same::value) if (this->n()*this->m()*src.n() > 300) { // In case we have the BLAS function gemm detected by CMake, we @@ -597,11 +597,11 @@ void FullMatrix::Tmmult (FullMatrix &dst, // works for us (it is usually not efficient to use BLAS for very small // matrices): #ifdef DEAL_II_WITH_LAPACK - if ((types_are_equal::value + if ((std::is_same::value || - types_are_equal::value) + std::is_same::value) && - types_are_equal::value) + std::is_same::value) if (this->n()*this->m()*src.n() > 300) { // In case we have the BLAS function gemm detected by CMake, we @@ -687,11 +687,11 @@ void FullMatrix::mTmult (FullMatrix &dst, // works for us (it is usually not efficient to use BLAS for very small // matrices): #ifdef DEAL_II_WITH_LAPACK - if ((types_are_equal::value + if ((std::is_same::value || - types_are_equal::value) + std::is_same::value) && - types_are_equal::value) + std::is_same::value) if (this->n()*this->m()*src.m() > 300) { // In case we have the BLAS function gemm detected by CMake, we @@ -775,11 +775,11 @@ void FullMatrix::TmTmult (FullMatrix &dst, // works for us (it is usually not efficient to use BLAS for very small // matrices): #ifdef DEAL_II_WITH_LAPACK - if ((types_are_equal::value + if ((std::is_same::value || - types_are_equal::value) + std::is_same::value) && - types_are_equal::value) + std::is_same::value) if (this->n()*this->m()*src.m() > 300) { // In case we have the BLAS function gemm detected by CMake, we @@ -1762,9 +1762,9 @@ FullMatrix::gauss_jordan () // efficient to use Lapack for very small // matrices): #ifdef DEAL_II_WITH_LAPACK - if (types_are_equal::value + if (std::is_same::value || - types_are_equal::value) + std::is_same::value) if (this->n_cols() > 15) { // In case we have the LAPACK functions diff --git a/include/deal.II/lac/precondition.h b/include/deal.II/lac/precondition.h index 1d1d504091..3e986e00db 100644 --- a/include/deal.II/lac/precondition.h +++ b/include/deal.II/lac/precondition.h @@ -2124,10 +2124,10 @@ PreconditionChebyshev::estimate_eigenv // We do not need the third auxiliary vector in case we have a // DiagonalMatrix as preconditioner and use deal.II's own vectors - if (types_are_equal >::value == false || - (types_are_equal >::value == false + if (std::is_same >::value == false || + (std::is_same >::value == false && - types_are_equal >::value == false + std::is_same >::value == false )) update3.reinit (src, true); diff --git a/include/deal.II/lac/solver_cg.h b/include/deal.II/lac/solver_cg.h index 7ec47b4467..41e78aa68b 100644 --- a/include/deal.II/lac/solver_cg.h +++ b/include/deal.II/lac/solver_cg.h @@ -402,7 +402,7 @@ SolverCG::solve (const MatrixType &A, return; } - if (types_are_equal::value == false) + if (std::is_same::value == false) { precondition.vmult(h,g); @@ -434,7 +434,7 @@ SolverCG::solve (const MatrixType &A, if (conv != SolverControl::iterate) break; - if (types_are_equal::value + if (std::is_same::value == false) { precondition.vmult(h,g); diff --git a/include/deal.II/lac/sparse_decomposition.templates.h b/include/deal.II/lac/sparse_decomposition.templates.h index 1adc70d93c..8bd5f9db44 100644 --- a/include/deal.II/lac/sparse_decomposition.templates.h +++ b/include/deal.II/lac/sparse_decomposition.templates.h @@ -163,7 +163,7 @@ SparseLUDecomposition::copy_from (const SparseMatrix &matrix const somenumber *input_ptr = matrix.val.get(); number *this_ptr = this->val.get(); const number *const end_ptr = this_ptr + this->n_nonzero_elements(); - if (types_are_equal::value == true) + if (std::is_same::value == true) std::memcpy (this_ptr, input_ptr, this->n_nonzero_elements()*sizeof(number)); else for ( ; this_ptr != end_ptr; ++input_ptr, ++this_ptr) diff --git a/include/deal.II/lac/vector_operations_internal.h b/include/deal.II/lac/vector_operations_internal.h index 35fc9762bf..e24c203041 100644 --- a/include/deal.II/lac/vector_operations_internal.h +++ b/include/deal.II/lac/vector_operations_internal.h @@ -228,7 +228,7 @@ namespace internal void operator() (const size_type begin, const size_type end) const { - if (types_are_equal::value) + if (std::is_same::value) std::memcpy(dst+begin, src+begin, (end-begin)*sizeof(Number)); else { @@ -689,7 +689,7 @@ namespace internal template struct Dot { - static const bool vectorizes = types_are_equal::value && + static const bool vectorizes = std::is_same::value && (VectorizedArray::n_array_elements > 1); Dot(const Number *X, const Number2 *Y) diff --git a/include/deal.II/matrix_free/fe_evaluation.h b/include/deal.II/matrix_free/fe_evaluation.h index 42b2d59eec..a9d29029fd 100644 --- a/include/deal.II/matrix_free/fe_evaluation.h +++ b/include/deal.II/matrix_free/fe_evaluation.h @@ -3083,7 +3083,7 @@ FEEvaluationBase for (unsigned int comp=0; comp::value>()); + std::integral_constant::value>()); } } @@ -3226,7 +3226,7 @@ FEEvaluationBase for (unsigned int j=0; j::n_array_elements) operation.process_dof_gather(dof_indices+ind, *src[0], values_dofs[comp][j], - std::integral_constant::value>()); + std::integral_constant::value>()); } } diff --git a/include/deal.II/matrix_free/shape_info.templates.h b/include/deal.II/matrix_free/shape_info.templates.h index 9bc6bea4fe..c003623273 100644 --- a/include/deal.II/matrix_free/shape_info.templates.h +++ b/include/deal.II/matrix_free/shape_info.templates.h @@ -378,7 +378,7 @@ namespace internal return false; const double zero_tol = - types_are_equal::value==true?1e-12:1e-7; + std::is_same::value==true?1e-12:1e-7; // symmetry for values const unsigned int n_dofs_1d = fe_degree + 1; for (unsigned int i=0; i<(n_dofs_1d+1)/2; ++i) @@ -480,7 +480,7 @@ namespace internal return false; const double zero_tol = - types_are_equal::value==true?1e-12:1e-7; + std::is_same::value==true?1e-12:1e-7; // check: identity operation for shape values const unsigned int n_points_1d = fe_degree+1; for (unsigned int i=0; i::Implementation const unsigned int dim = 2; unsigned int q_deg = fe.degree; - if (types_are_equal >::value) + if (std::is_same >::value) q_deg = fe.degree-1; // restricted to each face, the traces of the shape functions is an @@ -239,7 +239,7 @@ struct FE_Q_Base::Implementation const unsigned int dim = 3; unsigned int q_deg = fe.degree; - if (types_are_equal >::value) + if (std::is_same >::value) q_deg = fe.degree-1; // For a detailed documentation of the interpolation see the @@ -422,7 +422,7 @@ FE_Q_Base::FE_Q_Base : FE_Poly(poly_space, fe_data, restriction_is_additive_flags, std::vector(1, std::vector(1,true))), - q_degree (types_are_equal >::value + q_degree (std::is_same >::value ?this->degree-1 :this->degree) {} diff --git a/tests/lac/gmres_eigenvalues.cc b/tests/lac/gmres_eigenvalues.cc index 46436c188d..d1afe5ee91 100644 --- a/tests/lac/gmres_eigenvalues.cc +++ b/tests/lac/gmres_eigenvalues.cc @@ -67,7 +67,7 @@ void test (unsigned int variant) } else Assert(false, ExcMessage("Invalid variant")); - if (types_are_equal::value == true) + if (std::is_same::value == true) Assert(variant < 4, ExcMessage("Invalid_variant")); deallog.push(Utilities::int_to_string(variant,1)); diff --git a/tests/lac/gmres_reorthogonalize_01.cc b/tests/lac/gmres_reorthogonalize_01.cc index 5699d0b2d2..9f6bf86198 100644 --- a/tests/lac/gmres_reorthogonalize_01.cc +++ b/tests/lac/gmres_reorthogonalize_01.cc @@ -60,7 +60,7 @@ void test (unsigned int variant) matrix(i,i) = 1e30*(i+1)*(i+1)*(i+1)*(i+1); else Assert(false, ExcMessage("Invalid variant")); - if (types_are_equal::value == true) + if (std::is_same::value == true) Assert(variant < 4, ExcMessage("Invalid_variant")); deallog.push(Utilities::int_to_string(variant,1)); diff --git a/tests/lac/gmres_reorthogonalize_03.cc b/tests/lac/gmres_reorthogonalize_03.cc index 5a9d81e5e1..523f0a6604 100644 --- a/tests/lac/gmres_reorthogonalize_03.cc +++ b/tests/lac/gmres_reorthogonalize_03.cc @@ -59,7 +59,7 @@ void test (unsigned int variant) matrix(i,i) = 1e30*(i+1)*(i+1)*(i+1)*(i+1); else Assert(false, ExcMessage("Invalid variant")); - if (types_are_equal::value == true) + if (std::is_same::value == true) Assert(variant < 4, ExcMessage("Invalid_variant")); deallog.push(Utilities::int_to_string(variant,1)); diff --git a/tests/lac/la_vector_add_and_dot.cc b/tests/lac/la_vector_add_and_dot.cc index 92f58f37af..e727d6258c 100644 --- a/tests/lac/la_vector_add_and_dot.cc +++ b/tests/lac/la_vector_add_and_dot.cc @@ -43,7 +43,7 @@ void check () v1.add(factor, v2); const number prod = v1 * v3; const number prod_check = check.add_and_dot(factor, v2, v3); - if (test == 0 && types_are_equal::value) + if (test == 0 && std::is_same::value) { deallog << "Vector add reference: "; for (unsigned int i=0; i::value) + if (test == 0 && std::is_same::value) { deallog << "Vector add reference: "; v1.print(deallog); diff --git a/tests/matrix_free/get_functions_multife.cc b/tests/matrix_free/get_functions_multife.cc index 291c2390e9..c9df24a3b8 100644 --- a/tests/matrix_free/get_functions_multife.cc +++ b/tests/matrix_free/get_functions_multife.cc @@ -146,7 +146,7 @@ public: // for floats for the relative error size for (unsigned int i=0; i<2; ++i) { - if (types_are_equal::value == true) + if (std::is_same::value == true) { deallog << "Error function values FE " << i << ": " << errors[i*3+0]/total[i*3+0] << std::endl; @@ -164,7 +164,7 @@ public: const double output2 = total[i*3+2] == 0 ? 0. : errors[i*3+2] / total[i*3+2]; deallog << "Error function Laplacians FE " << i << ": " << output2 << std::endl; } - else if (types_are_equal::value == true) + else if (std::is_same::value == true) { deallog << "Error function values FE " << i << ": " << errors[i*3+0]/total[i*3+0] << std::endl; diff --git a/tests/matrix_free/get_functions_multife2.cc b/tests/matrix_free/get_functions_multife2.cc index 32eb2a3f87..81a42292e3 100644 --- a/tests/matrix_free/get_functions_multife2.cc +++ b/tests/matrix_free/get_functions_multife2.cc @@ -185,7 +185,7 @@ public: // for floats for the relative error size for (unsigned int i=0; i<3; ++i) { - if (types_are_equal::value == true) + if (std::is_same::value == true) { deallog << "Error function values FE " << i << ": " << errors[i*3+0]/total[i*3+0] << std::endl; @@ -203,7 +203,7 @@ public: const double output2 = total[i*3+2] == 0 ? 0. : errors[i*3+2] / total[i*3+2]; deallog << "Error function Laplacians FE " << i << ": " << output2 << std::endl; } - else if (types_are_equal::value == true) + else if (std::is_same::value == true) { deallog << "Error function values FE " << i << ": " << errors[i*3+0]/total[i*3+0] << std::endl; diff --git a/tests/matrix_free/parallel_multigrid.cc b/tests/matrix_free/parallel_multigrid.cc index d256d4efb1..d01c5e6e8c 100644 --- a/tests/matrix_free/parallel_multigrid.cc +++ b/tests/matrix_free/parallel_multigrid.cc @@ -305,7 +305,7 @@ public: template void do_test (const DoFHandler &dof) { - if (types_are_equal::value == true) + if (std::is_same::value == true) { deallog.push("float"); } @@ -383,7 +383,7 @@ void do_test (const DoFHandler &dof) solver.solve(fine_matrix, sol, in, preconditioner); } - if (types_are_equal::value == true) + if (std::is_same::value == true) deallog.pop(); } diff --git a/tests/matrix_free/parallel_multigrid_02.cc b/tests/matrix_free/parallel_multigrid_02.cc index ed61d84c8d..84db5993b5 100644 --- a/tests/matrix_free/parallel_multigrid_02.cc +++ b/tests/matrix_free/parallel_multigrid_02.cc @@ -76,7 +76,7 @@ using namespace dealii::MatrixFreeOperators; template void do_test (const DoFHandler &dof) { - if (types_are_equal::value == true) + if (std::is_same::value == true) { deallog.push("float"); } @@ -199,7 +199,7 @@ void do_test (const DoFHandler &dof) solver.solve(fine_matrix, sol, in, preconditioner); } - if (types_are_equal::value == true) + if (std::is_same::value == true) deallog.pop(); fine_matrix.clear(); diff --git a/tests/matrix_free/parallel_multigrid_adaptive_01.cc b/tests/matrix_free/parallel_multigrid_adaptive_01.cc index 0b1c9bd12d..bfd6eb2d4f 100644 --- a/tests/matrix_free/parallel_multigrid_adaptive_01.cc +++ b/tests/matrix_free/parallel_multigrid_adaptive_01.cc @@ -432,7 +432,7 @@ public: template void do_test (const DoFHandler &dof) { - if (types_are_equal::value == true) + if (std::is_same::value == true) { deallog.push("float"); } @@ -536,7 +536,7 @@ void do_test (const DoFHandler &dof) solver.solve(fine_matrix, sol, in, preconditioner); } - if (types_are_equal::value == true) + if (std::is_same::value == true) deallog.pop(); } diff --git a/tests/matrix_free/parallel_multigrid_adaptive_02.cc b/tests/matrix_free/parallel_multigrid_adaptive_02.cc index d5a7acbbad..f59a080187 100644 --- a/tests/matrix_free/parallel_multigrid_adaptive_02.cc +++ b/tests/matrix_free/parallel_multigrid_adaptive_02.cc @@ -113,7 +113,7 @@ public: template void do_test (const DoFHandler &dof) { - if (types_are_equal::value == true) + if (std::is_same::value == true) { deallog.push("float"); } @@ -259,7 +259,7 @@ void do_test (const DoFHandler &dof) solver.solve(fine_matrix, sol, in, preconditioner); } - if (types_are_equal::value == true) + if (std::is_same::value == true) deallog.pop(); fine_matrix.clear(); diff --git a/tests/matrix_free/parallel_multigrid_adaptive_04.cc b/tests/matrix_free/parallel_multigrid_adaptive_04.cc index 41886c1a2b..155dca3805 100644 --- a/tests/matrix_free/parallel_multigrid_adaptive_04.cc +++ b/tests/matrix_free/parallel_multigrid_adaptive_04.cc @@ -113,7 +113,7 @@ public: template void do_test (const DoFHandler &dof) { - if (types_are_equal::value == true) + if (std::is_same::value == true) { deallog.push("float"); } @@ -259,7 +259,7 @@ void do_test (const DoFHandler &dof) solver.solve(fine_matrix, sol, in, preconditioner); } - if (types_are_equal::value == true) + if (std::is_same::value == true) deallog.pop(); fine_matrix.clear(); -- 2.39.5