From: Timo Heister Date: Fri, 3 Feb 2017 17:54:12 +0000 (-0500) Subject: Revert "add new macro for static asserts" X-Git-Tag: v8.5.0-rc1~151^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F3923%2Fhead;p=dealii.git Revert "add new macro for static asserts" This reverts commit c9283e795004308c570f356da95f97562f62d112. --- diff --git a/include/deal.II/base/exceptions.h b/include/deal.II/base/exceptions.h index c0ed32c46d..5dfca28ebc 100644 --- a/include/deal.II/base/exceptions.h +++ b/include/deal.II/base/exceptions.h @@ -1228,18 +1228,6 @@ namespace StandardExceptions dealii::ExcCudaError(cudaGetErrorString(error_code))) #endif -// A static assert which checks a compile-time condition. This is nothing more -// than a wrapper around the C++11 static_assert declaration, which -// we need to disable for non-C++11. - -// Just like static_assert, it takes two arguments, a -// constexpr condition and an error message. -#if defined(DEAL_II_WITH_CXX11) -#define DEAL_II_STATIC_ASSERT(...) static_assert(__VA_ARGS__) -#else -#define DEAL_II_STATIC_ASSERT(...) /* do nothing */ -#endif - using namespace StandardExceptions; DEAL_II_NAMESPACE_CLOSE diff --git a/include/deal.II/base/quadrature_point_data.h b/include/deal.II/base/quadrature_point_data.h index 968dfead38..f3a4b5ff27 100644 --- a/include/deal.II/base/quadrature_point_data.h +++ b/include/deal.II/base/quadrature_point_data.h @@ -21,7 +21,6 @@ #ifdef DEAL_II_WITH_CXX11 -#include #include #include #include @@ -327,8 +326,8 @@ namespace parallel class ContinuousQuadratureDataTransfer { public: - DEAL_II_STATIC_ASSERT(std::is_base_of::value, - "User's DataType class should be derived from QPData"); + static_assert(std::is_base_of::value, + "User's DataType class should be derived from QPData"); /** * A typedef for a cell. @@ -506,8 +505,8 @@ template void CellDataStorage::initialize(const CellIteratorType &cell, const unsigned int n_q_points) { - DEAL_II_STATIC_ASSERT(std::is_base_of::value, - "User's T class should be derived from user's DataType class"); + static_assert(std::is_base_of::value, + "User's T class should be derived from user's DataType class"); if (map.find(cell) == map.end()) { @@ -578,8 +577,8 @@ template std::vector > CellDataStorage::get_data(const CellIteratorType &cell) { - DEAL_II_STATIC_ASSERT(std::is_base_of::value, - "User's T class should be derived from user's DataType class"); + static_assert(std::is_base_of::value, + "User's T class should be derived from user's DataType class"); auto it = map.find(cell); Assert(it != map.end(), ExcMessage("Could not find data for the cell")); @@ -602,8 +601,8 @@ template std::vector > CellDataStorage::get_data(const CellIteratorType &cell) const { - DEAL_II_STATIC_ASSERT(std::is_base_of::value, - "User's T class should be derived from user's DataType class"); + static_assert(std::is_base_of::value, + "User's T class should be derived from user's DataType class"); auto it = map.find(cell); Assert(it != map.end(), ExcMessage("Could not find QP data for the cell")); @@ -635,8 +634,8 @@ void pack_cell_data const CellDataStorage *data_storage, FullMatrix &matrix_data) { - DEAL_II_STATIC_ASSERT(std::is_base_of::value, - "User's DataType class should be derived from QPData"); + static_assert(std::is_base_of::value, + "User's DataType class should be derived from QPData"); const std::vector > qpd = data_storage->get_data(cell); @@ -668,8 +667,8 @@ void unpack_to_cell_data const FullMatrix &values_at_qp, CellDataStorage *data_storage) { - DEAL_II_STATIC_ASSERT(std::is_base_of::value, - "User's DataType class should be derived from QPData"); + static_assert(std::is_base_of::value, + "User's DataType class should be derived from QPData"); std::vector > qpd = data_storage->get_data(cell); diff --git a/include/deal.II/base/tensor_accessors.h b/include/deal.II/base/tensor_accessors.h index 3bec92b90e..f366cd415f 100644 --- a/include/deal.II/base/tensor_accessors.h +++ b/include/deal.II/base/tensor_accessors.h @@ -17,7 +17,6 @@ #define dealii__tensor_accessors_h #include -#include #include #include @@ -186,8 +185,10 @@ namespace TensorAccessors internal::ReorderedIndexView reordered_index_view(T &t) { - DEAL_II_STATIC_ASSERT(0 <= index && index < rank, - "The specified index must lie within the range [0,rank)"); +#ifdef DEAL_II_WITH_CXX11 + static_assert(0 <= index && index < rank, + "The specified index must lie within the range [0,rank)"); +#endif return internal::ReorderedIndexView(t); } @@ -265,12 +266,14 @@ namespace TensorAccessors inline DEAL_II_ALWAYS_INLINE void contract(T1 &result, const T2 &left, const T3 &right) { - DEAL_II_STATIC_ASSERT(rank_1 >= no_contr, "The rank of the left tensor must be " - "equal or greater than the number of " - "contractions"); - DEAL_II_STATIC_ASSERT(rank_2 >= no_contr, "The rank of the right tensor must be " - "equal or greater than the number of " - "contractions"); +#ifdef DEAL_II_WITH_CXX11 + static_assert(rank_1 >= no_contr, "The rank of the left tensor must be " + "equal or greater than the number of " + "contractions"); + static_assert(rank_2 >= no_contr, "The rank of the right tensor must be " + "equal or greater than the number of " + "contractions"); +#endif internal::Contract::template contract (result, left, right); diff --git a/include/deal.II/dofs/dof_handler.h b/include/deal.II/dofs/dof_handler.h index 35209b5193..765c79a779 100644 --- a/include/deal.II/dofs/dof_handler.h +++ b/include/deal.II/dofs/dof_handler.h @@ -1096,10 +1096,12 @@ private: // explicitly check for sensible template arguments, but not on windows // because MSVC creates bogus warnings during normal compilation +#ifdef DEAL_II_WITH_CXX11 #ifndef DEAL_II_MSVC - DEAL_II_STATIC_ASSERT (dim<=spacedim, - "The dimension of a DoFHandler must be less than or " - "equal to the space dimension in which it lives."); + static_assert (dim<=spacedim, + "The dimension of a DoFHandler must be less than or " + "equal to the space dimension in which it lives."); +#endif #endif }; diff --git a/include/deal.II/fe/fe.h b/include/deal.II/fe/fe.h index dc22005681..95fb372ebb 100644 --- a/include/deal.II/fe/fe.h +++ b/include/deal.II/fe/fe.h @@ -2725,10 +2725,12 @@ protected: // explicitly check for sensible template arguments, but not on windows // because MSVC creates bogus warnings during normal compilation +#ifdef DEAL_II_WITH_CXX11 #ifndef DEAL_II_MSVC - DEAL_II_STATIC_ASSERT (dim<=spacedim, - "The dimension of a FiniteElement must be less than or " - "equal to the space dimension in which it lives."); + static_assert (dim<=spacedim, + "The dimension of a FiniteElement must be less than or " + "equal to the space dimension in which it lives."); +#endif #endif }; diff --git a/include/deal.II/grid/manifold.h b/include/deal.II/grid/manifold.h index 8cfc3f899c..8e97d71509 100644 --- a/include/deal.II/grid/manifold.h +++ b/include/deal.II/grid/manifold.h @@ -299,9 +299,11 @@ class Manifold : public Subscriptor public: // explicitly check for sensible template arguments - DEAL_II_STATIC_ASSERT (dim<=spacedim, - "The dimension of a Manifold must be less than or " - "equal to the space dimension in which it lives."); +#ifdef DEAL_II_WITH_CXX11 + static_assert (dim<=spacedim, + "The dimension of a Manifold must be less than or " + "equal to the space dimension in which it lives."); +#endif /** @@ -886,9 +888,11 @@ class ChartManifold : public Manifold { public: // explicitly check for sensible template arguments - DEAL_II_STATIC_ASSERT (dim<=spacedim, - "The dimension of a ChartManifold must be less than or " - "equal to the space dimension in which it lives."); +#ifdef DEAL_II_WITH_CXX11 + static_assert (dim<=spacedim, + "The dimension of a ChartManifold must be less than or " + "equal to the space dimension in which it lives."); +#endif /** * Constructor. The optional argument can be used to specify the periodicity diff --git a/include/deal.II/grid/tria.h b/include/deal.II/grid/tria.h index 7e68ed6c4f..b1380ae512 100644 --- a/include/deal.II/grid/tria.h +++ b/include/deal.II/grid/tria.h @@ -3528,10 +3528,12 @@ private: // explicitly check for sensible template arguments, but not on windows // because MSVC creates bogus warnings during normal compilation +#ifdef DEAL_II_WITH_CXX11 #ifndef DEAL_II_MSVC - DEAL_II_STATIC_ASSERT (dim<=spacedim, - "The dimension of a Triangulation must be less than or " - "equal to the space dimension in which it lives."); + static_assert (dim<=spacedim, + "The dimension of a Triangulation must be less than or " + "equal to the space dimension in which it lives."); +#endif #endif }; diff --git a/include/deal.II/lac/block_linear_operator.h b/include/deal.II/lac/block_linear_operator.h index a5995cfc98..74d3aa19c5 100644 --- a/include/deal.II/lac/block_linear_operator.h +++ b/include/deal.II/lac/block_linear_operator.h @@ -502,8 +502,8 @@ template block_operator(const std::array, n>, m> &ops) { - DEAL_II_STATIC_ASSERT(m > 0 && n > 0, - "a blocked LinearOperator must consist of at least one block"); + static_assert(m > 0 && n > 0, + "a blocked LinearOperator must consist of at least one block"); typedef typename BlockLinearOperator::BlockType BlockType; @@ -611,8 +611,8 @@ template BlockLinearOperator block_diagonal_operator(const std::array, m> &ops) { - DEAL_II_STATIC_ASSERT(m > 0, - "a blockdiagonal LinearOperator must consist of at least one block"); + static_assert(m > 0, + "a blockdiagonal LinearOperator must consist of at least one block"); typedef typename BlockLinearOperator::BlockType BlockType; @@ -655,9 +655,9 @@ template BlockLinearOperator block_diagonal_operator(const LinearOperator &op) { - DEAL_II_STATIC_ASSERT(m > 0, - "a blockdiagonal LinearOperator must consist of at least " - "one block"); + static_assert(m > 0, + "a blockdiagonal LinearOperator must consist of at least " + "one block"); typedef typename BlockLinearOperator::BlockType BlockType; std::array new_ops; diff --git a/include/deal.II/lac/block_vector_base.h b/include/deal.II/lac/block_vector_base.h index 01d47e2257..69506a8ef0 100644 --- a/include/deal.II/lac/block_vector_base.h +++ b/include/deal.II/lac/block_vector_base.h @@ -1044,9 +1044,9 @@ namespace internal // true). As mentioned above, try to check this at compile time if C++11 // support is available. #ifdef DEAL_II_WITH_CXX11 - DEAL_II_STATIC_ASSERT(Constness == true, - "Constructing a non-const iterator from a const iterator " - "does not make sense."); + static_assert(Constness == true, + "Constructing a non-const iterator from a const iterator " + "does not make sense."); #else Assert(Constness == true, ExcCastingAwayConstness()); #endif diff --git a/include/deal.II/lac/linear_operator.h b/include/deal.II/lac/linear_operator.h index cde2a61bec..1403d17d7a 100644 --- a/include/deal.II/lac/linear_operator.h +++ b/include/deal.II/lac/linear_operator.h @@ -466,7 +466,7 @@ LinearOperator operator*(typename Range::value_type number, const LinearOperator &op) { - DEAL_II_STATIC_ASSERT( + static_assert( std::is_convertible::value, "Range and Domain must have implicitly convertible 'value_type's"); @@ -536,7 +536,7 @@ LinearOperator operator*(const LinearOperator &op, typename Domain::value_type number) { - DEAL_II_STATIC_ASSERT( + static_assert( std::is_convertible::value, "Range and Domain must have implicitly convertible 'value_type's"); diff --git a/include/deal.II/lac/precondition.h b/include/deal.II/lac/precondition.h index 7e56a87ffd..20fe5e1a25 100644 --- a/include/deal.II/lac/precondition.h +++ b/include/deal.II/lac/precondition.h @@ -19,7 +19,6 @@ // This file contains simple preconditioners. #include -#include #include #include #include @@ -1255,9 +1254,11 @@ template inline void PreconditionRichardson::vmult (VectorType &dst, const VectorType &src) const { - DEAL_II_STATIC_ASSERT( +#ifdef DEAL_II_WITH_CXX11 + static_assert( std::is_same::value, "PreconditionRichardson and VectorType must have the same size_type."); +#endif // DEAL_II_WITH_CXX11 dst.equ(relaxation,src); } @@ -1268,9 +1269,11 @@ template inline void PreconditionRichardson::Tvmult (VectorType &dst, const VectorType &src) const { - DEAL_II_STATIC_ASSERT( +#ifdef DEAL_II_WITH_CXX11 + static_assert( std::is_same::value, "PreconditionRichardson and VectorType must have the same size_type."); +#endif // DEAL_II_WITH_CXX11 dst.equ(relaxation,src); } @@ -1279,9 +1282,11 @@ template inline void PreconditionRichardson::vmult_add (VectorType &dst, const VectorType &src) const { - DEAL_II_STATIC_ASSERT( +#ifdef DEAL_II_WITH_CXX11 + static_assert( std::is_same::value, "PreconditionRichardson and VectorType must have the same size_type."); +#endif // DEAL_II_WITH_CXX11 dst.add(relaxation,src); } @@ -1292,9 +1297,11 @@ template inline void PreconditionRichardson::Tvmult_add (VectorType &dst, const VectorType &src) const { - DEAL_II_STATIC_ASSERT( +#ifdef DEAL_II_WITH_CXX11 + static_assert( std::is_same::value, "PreconditionRichardson and VectorType must have the same size_type."); +#endif // DEAL_II_WITH_CXX11 dst.add(relaxation,src); } @@ -1355,9 +1362,11 @@ template inline void PreconditionJacobi::vmult (VectorType &dst, const VectorType &src) const { - DEAL_II_STATIC_ASSERT( +#ifdef DEAL_II_WITH_CXX11 + static_assert( std::is_same::size_type, typename VectorType::size_type>::value, "PreconditionJacobi and VectorType must have the same size_type."); +#endif // DEAL_II_WITH_CXX11 Assert (this->A!=0, ExcNotInitialized()); this->A->precondition_Jacobi (dst, src, this->relaxation); @@ -1370,9 +1379,11 @@ template inline void PreconditionJacobi::Tvmult (VectorType &dst, const VectorType &src) const { - DEAL_II_STATIC_ASSERT( +#ifdef DEAL_II_WITH_CXX11 + static_assert( std::is_same::size_type, typename VectorType::size_type>::value, "PreconditionJacobi and VectorType must have the same size_type."); +#endif // DEAL_II_WITH_CXX11 Assert (this->A!=0, ExcNotInitialized()); this->A->precondition_Jacobi (dst, src, this->relaxation); @@ -1385,9 +1396,11 @@ template inline void PreconditionJacobi::step (VectorType &dst, const VectorType &src) const { - DEAL_II_STATIC_ASSERT( +#ifdef DEAL_II_WITH_CXX11 + static_assert( std::is_same::size_type, typename VectorType::size_type>::value, "PreconditionJacobi and VectorType must have the same size_type."); +#endif // DEAL_II_WITH_CXX11 Assert (this->A!=0, ExcNotInitialized()); this->A->Jacobi_step (dst, src, this->relaxation); @@ -1400,9 +1413,11 @@ template inline void PreconditionJacobi::Tstep (VectorType &dst, const VectorType &src) const { - DEAL_II_STATIC_ASSERT( +#ifdef DEAL_II_WITH_CXX11 + static_assert( std::is_same::size_type, typename VectorType::size_type>::value, "PreconditionJacobi and VectorType must have the same size_type."); +#endif // DEAL_II_WITH_CXX11 step (dst, src); } @@ -1416,9 +1431,11 @@ template inline void PreconditionSOR::vmult (VectorType &dst, const VectorType &src) const { - DEAL_II_STATIC_ASSERT( +#ifdef DEAL_II_WITH_CXX11 + static_assert( std::is_same::size_type, typename VectorType::size_type>::value, "PreconditionSOR and VectorType must have the same size_type."); +#endif // DEAL_II_WITH_CXX11 Assert (this->A!=0, ExcNotInitialized()); this->A->precondition_SOR (dst, src, this->relaxation); @@ -1431,9 +1448,11 @@ template inline void PreconditionSOR::Tvmult (VectorType &dst, const VectorType &src) const { - DEAL_II_STATIC_ASSERT( +#ifdef DEAL_II_WITH_CXX11 + static_assert( std::is_same::size_type, typename VectorType::size_type>::value, "PreconditionSOR and VectorType must have the same size_type."); +#endif // DEAL_II_WITH_CXX11 Assert (this->A!=0, ExcNotInitialized()); this->A->precondition_TSOR (dst, src, this->relaxation); @@ -1446,9 +1465,11 @@ template inline void PreconditionSOR::step (VectorType &dst, const VectorType &src) const { - DEAL_II_STATIC_ASSERT( +#ifdef DEAL_II_WITH_CXX11 + static_assert( std::is_same::size_type, typename VectorType::size_type>::value, "PreconditionSOR and VectorType must have the same size_type."); +#endif // DEAL_II_WITH_CXX11 Assert (this->A!=0, ExcNotInitialized()); this->A->SOR_step (dst, src, this->relaxation); @@ -1461,9 +1482,11 @@ template inline void PreconditionSOR::Tstep (VectorType &dst, const VectorType &src) const { - DEAL_II_STATIC_ASSERT( +#ifdef DEAL_II_WITH_CXX11 + static_assert( std::is_same::size_type, typename VectorType::size_type>::value, "PreconditionSOR and VectorType must have the same size_type."); +#endif // DEAL_II_WITH_CXX11 Assert (this->A!=0, ExcNotInitialized()); this->A->TSOR_step (dst, src, this->relaxation); @@ -1512,9 +1535,11 @@ template inline void PreconditionSSOR::vmult (VectorType &dst, const VectorType &src) const { - DEAL_II_STATIC_ASSERT( +#ifdef DEAL_II_WITH_CXX11 + static_assert( std::is_same::size_type, typename VectorType::size_type>::value, "PreconditionSSOR and VectorType must have the same size_type."); +#endif // DEAL_II_WITH_CXX11 Assert (this->A!=0, ExcNotInitialized()); this->A->precondition_SSOR (dst, src, this->relaxation, pos_right_of_diagonal); @@ -1527,9 +1552,11 @@ template inline void PreconditionSSOR::Tvmult (VectorType &dst, const VectorType &src) const { - DEAL_II_STATIC_ASSERT( +#ifdef DEAL_II_WITH_CXX11 + static_assert( std::is_same::size_type, typename VectorType::size_type>::value, "PreconditionSSOR and VectorType must have the same size_type."); +#endif // DEAL_II_WITH_CXX11 Assert (this->A!=0, ExcNotInitialized()); this->A->precondition_SSOR (dst, src, this->relaxation, pos_right_of_diagonal); @@ -1542,9 +1569,11 @@ template inline void PreconditionSSOR::step (VectorType &dst, const VectorType &src) const { - DEAL_II_STATIC_ASSERT( +#ifdef DEAL_II_WITH_CXX11 + static_assert( std::is_same::size_type, typename VectorType::size_type>::value, "PreconditionSSOR and VectorType must have the same size_type."); +#endif // DEAL_II_WITH_CXX11 Assert (this->A!=0, ExcNotInitialized()); this->A->SSOR_step (dst, src, this->relaxation); @@ -1557,9 +1586,11 @@ template inline void PreconditionSSOR::Tstep (VectorType &dst, const VectorType &src) const { - DEAL_II_STATIC_ASSERT( +#ifdef DEAL_II_WITH_CXX11 + static_assert( std::is_same::size_type, typename VectorType::size_type>::value, "PreconditionSSOR and VectorType must have the same size_type."); +#endif // DEAL_II_WITH_CXX11 step (dst, src); } @@ -1599,9 +1630,11 @@ template inline void PreconditionPSOR::vmult (VectorType &dst, const VectorType &src) const { - DEAL_II_STATIC_ASSERT( +#ifdef DEAL_II_WITH_CXX11 + static_assert( std::is_same::size_type, typename VectorType::size_type>::value, "PreconditionPSOR and VectorType must have the same size_type."); +#endif // DEAL_II_WITH_CXX11 Assert (this->A!=0, ExcNotInitialized()); dst = src; @@ -1615,9 +1648,11 @@ template inline void PreconditionPSOR::Tvmult (VectorType &dst, const VectorType &src) const { - DEAL_II_STATIC_ASSERT( +#ifdef DEAL_II_WITH_CXX11 + static_assert( std::is_same::size_type, typename VectorType::size_type>::value, "PreconditionPSOR and VectorType must have the same size_type."); +#endif // DEAL_II_WITH_CXX11 Assert (this->A!=0, ExcNotInitialized()); dst = src; @@ -1981,9 +2016,11 @@ PreconditionChebyshev::PreconditionChe delta (1.), is_initialized (false) { - DEAL_II_STATIC_ASSERT( +#ifdef DEAL_II_WITH_CXX11 + static_assert( std::is_same::value, "PreconditionChebyshev and VectorType must have the same size_type."); +#endif // DEAL_II_WITH_CXX11 } diff --git a/include/deal.II/lac/trilinos_block_sparse_matrix.h b/include/deal.II/lac/trilinos_block_sparse_matrix.h index f5494a060d..8015170f97 100644 --- a/include/deal.II/lac/trilinos_block_sparse_matrix.h +++ b/include/deal.II/lac/trilinos_block_sparse_matrix.h @@ -608,8 +608,8 @@ namespace TrilinosWrappers template TrilinosBlockPayload (const Args &...) { - DEAL_II_STATIC_ASSERT(typeid(PayloadBlockType)==typeid(internal::LinearOperator::TrilinosPayload), - "TrilinosBlockPayload can only accept a payload of type TrilinosPayload."); + static_assert(typeid(PayloadBlockType)==typeid(internal::LinearOperator::TrilinosPayload), + "TrilinosBlockPayload can only accept a payload of type TrilinosPayload."); } }; diff --git a/include/deal.II/matrix_free/operators.h b/include/deal.II/matrix_free/operators.h index 2cd356bf4d..72e7c170eb 100644 --- a/include/deal.II/matrix_free/operators.h +++ b/include/deal.II/matrix_free/operators.h @@ -1097,9 +1097,13 @@ namespace MatrixFreeOperators MGInterfaceOperator::vmult (VectorType &dst, const VectorType &src) const { - DEAL_II_STATIC_ASSERT (std::is_same::value, - "The vector type must be based on the same value type as this" - "operator"); +#ifdef DEAL_II_WITH_CXX11 +#ifndef DEAL_II_MSVC + static_assert (std::is_same::value, + "The vector type must be based on the same value type as this" + "operator"); +#endif +#endif Assert(mf_base_operator != NULL, ExcNotInitialized()); @@ -1115,9 +1119,13 @@ namespace MatrixFreeOperators MGInterfaceOperator::Tvmult (VectorType &dst, const VectorType &src) const { - DEAL_II_STATIC_ASSERT (std::is_same::value, - "The vector type must be based on the same value type as this" - "operator"); +#ifdef DEAL_II_WITH_CXX11 +#ifndef DEAL_II_MSVC + static_assert (std::is_same::value, + "The vector type must be based on the same value type as this" + "operator"); +#endif +#endif Assert(mf_base_operator != NULL, ExcNotInitialized());