From 3e400d4ecc3298e220c98bc3fa83cb130a2ea176 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 21 Aug 2018 15:55:04 -0600 Subject: [PATCH] Use std::conditional instead of a switch class. --- include/deal.II/lac/block_vector_base.h | 96 +++---------------------- 1 file changed, 10 insertions(+), 86 deletions(-) diff --git a/include/deal.II/lac/block_vector_base.h b/include/deal.II/lac/block_vector_base.h index d2b5217554..b9ab9d8308 100644 --- a/include/deal.II/lac/block_vector_base.h +++ b/include/deal.II/lac/block_vector_base.h @@ -115,87 +115,6 @@ namespace internal */ namespace BlockVectorIterators { - /** - * Declaration of the general template of a structure which is used to - * determine some types based on the template arguments of other classes. - */ - template - struct Types - {}; - - - - /** - * Declaration of a specialized template of a structure which is used to - * determine some types based on the template arguments of other classes. - * - * This is for the use of non-const iterators. - */ - template - struct Types - { - /** - * Type of the vector underlying the block vector used in non-const - * iterators. There, the vector must not be constant. - */ - using Vector = typename BlockVectorType::BlockType; - - /** - * Type of the block vector used in non-const iterators. There, the - * block vector must not be constant. - */ - using BlockVector = BlockVectorType; - - /** - * Type of the numbers we point to. Here, they are not constant. - */ - using value_type = typename BlockVector::value_type; - - /** - * Typedef the result of a dereferencing operation for an iterator of - * the underlying iterator. - */ - using dereference_type = typename Vector::reference; - }; - - - - /** - * Declaration of a specialized template of a structure which is used to - * determine some types based on the template arguments of other classes. - * - * This is for the use of const_iterator. - */ - template - struct Types - { - /** - * Type of the vector underlying the block vector used in - * const_iterator. There, the vector must be constant. - */ - using Vector = const typename BlockVectorType::BlockType; - - /** - * Type of the block vector used in const_iterator. There, the block - * vector must be constant. - */ - using BlockVector = const BlockVectorType; - - /** - * Type of the numbers we point to. Here, they are constant since the - * block vector we use is constant. - */ - using value_type = const typename BlockVector::value_type; - - /** - * Typedef the result of a dereferencing operation for an iterator of - * the underlying iterator. Since this is for constant iterators, we can - * only return values, not actual references. - */ - using dereference_type = value_type; - }; - - /** * General random-access iterator class for block vectors. Since we do not * want to have two classes for non-const iterator and const_iterator, we @@ -227,7 +146,10 @@ namespace internal * the second template parameter, this is either a constant or non-const * number. */ - using value_type = typename Types::value_type; + using value_type = + typename std::conditional::type; /** * Declare some alias which are standard for iterators and are used @@ -239,15 +161,17 @@ namespace internal using reference = typename BlockVectorType::reference; using pointer = value_type *; - using dereference_type = - typename Types::dereference_type; + using dereference_type = typename std::conditional< + Constness, + value_type, + typename BlockVectorType::BlockType::reference>::type; /** * Typedef the type of the block vector (which differs in constness, * depending on the second template parameter). */ - using BlockVector = - typename Types::BlockVector; + using BlockVector = typename std:: + conditional::type; /** * Construct an iterator from a vector to which we point and the global -- 2.39.5