[dune-pdelab] Dune::array in dune-typetree

Christian Engwer christian.engwer at uni-muenster.de
Thu Jul 9 11:28:39 CEST 2015


Thanks! Patch applied


On Thu, Jul 09, 2015 at 11:25:17AM +0200, Oliver Sander wrote:
> Dear pdelab team,
> the attached patch replaces all occurrences in dune-typetree (that I could find)
> by std::array.  I hope sending a patch is okay, or is dune-typetree also merge-request
> only?
> Best,
> Oliver

> From 5c43a3e2941d479a7dc919b639ad1be11224184f Mon Sep 17 00:00:00 2001
> From: Oliver Sander <sander at igpm.rwth-aachen.de>
> Date: Thu, 9 Jul 2015 11:23:21 +0200
> Subject: [PATCH] [cleanup] Use std::array instead of Dune::array
> 
> ---
>  dune/typetree/fixedcapacitystack.hh               |  6 +++---
>  dune/typetree/generictransformationdescriptors.hh |  9 +++++----
>  dune/typetree/powernode.hh                        |  8 ++++----
>  dune/typetree/simpletransformationdescriptors.hh  |  7 ++++---
>  dune/typetree/transformation.hh                   | 15 ++++++++-------
>  test/typetreetargetnodes.hh                       |  4 ++--
>  6 files changed, 26 insertions(+), 23 deletions(-)
> 
> diff --git a/dune/typetree/fixedcapacitystack.hh b/dune/typetree/fixedcapacitystack.hh
> index c8a9925..45fdc01 100644
> --- a/dune/typetree/fixedcapacitystack.hh
> +++ b/dune/typetree/fixedcapacitystack.hh
> @@ -4,7 +4,7 @@
>  #ifndef DUNE_TYPETREE_FIXEDCAPACITYSTACK_HH
>  #define DUNE_TYPETREE_FIXEDCAPACITYSTACK_HH
>  
> -#include <dune/common/array.hh>
> +#include <array>
>  #include <cassert>
>  
>  namespace Dune {
> @@ -117,7 +117,7 @@ namespace Dune {
>  
>      template<typename T, std::size_t capacity>
>      class FixedCapacityStack
> -      : private array<T,capacity>
> +      : private std::array<T,capacity>
>        , private FixedCapacityStackView<T>::Impl
>        , public FixedCapacityStackView<T>
>      {
> @@ -132,7 +132,7 @@ namespace Dune {
>        using view_base::operator[];
>  
>        FixedCapacityStack()
> -        : FixedCapacityStackView<T>::Impl(&(static_cast<array<T,capacity>&>(*this)[0]),capacity)
> +        : FixedCapacityStackView<T>::Impl(&(static_cast<std::array<T,capacity>&>(*this)[0]),capacity)
>          , FixedCapacityStackView<T>(static_cast<typename FixedCapacityStackView<T>::Impl&>(*this))
>        {}
>  
> diff --git a/dune/typetree/generictransformationdescriptors.hh b/dune/typetree/generictransformationdescriptors.hh
> index b913bfc..53a627c 100644
> --- a/dune/typetree/generictransformationdescriptors.hh
> +++ b/dune/typetree/generictransformationdescriptors.hh
> @@ -4,11 +4,12 @@
>  #ifndef DUNE_TYPETREE_GENERICTRANSFORMATIONDESCRIPTORS_HH
>  #define DUNE_TYPETREE_GENERICTRANSFORMATIONDESCRIPTORS_HH
>  
> +#include <array>
> +
>  #include <dune/typetree/nodetags.hh>
>  #include <dune/typetree/powercompositenodetransformationtemplates.hh>
>  #include <dune/common/exceptions.hh>
>  #include <dune/common/shared_ptr.hh>
> -#include <dune/common/array.hh>
>  #include <dune/common/tuples.hh>
>  
>  
> @@ -61,19 +62,19 @@ namespace Dune {
>        };
>  
>        template<typename TC>
> -      static typename result<TC>::type transform(const SourceNode& s, const Transformation& t, const array<shared_ptr<TC>,result<TC>::type::CHILDREN>& children)
> +      static typename result<TC>::type transform(const SourceNode& s, const Transformation& t, const std::array<shared_ptr<TC>,result<TC>::type::CHILDREN>& children)
>        {
>          return typename result<TC>::type(s,t,children);
>        }
>  
>        template<typename TC>
> -      static typename result<TC>::type transform(shared_ptr<const SourceNode> s, const Transformation& t, const array<shared_ptr<TC>,result<TC>::type::CHILDREN>& children)
> +      static typename result<TC>::type transform(shared_ptr<const SourceNode> s, const Transformation& t, const std::array<shared_ptr<TC>,result<TC>::type::CHILDREN>& children)
>        {
>          return typename result<TC>::type(s,t,children);
>        }
>  
>        template<typename TC>
> -      static typename result<TC>::storage_type transform_storage(shared_ptr<const SourceNode> s, const Transformation& t, const array<shared_ptr<TC>,result<TC>::type::CHILDREN>& children)
> +      static typename result<TC>::storage_type transform_storage(shared_ptr<const SourceNode> s, const Transformation& t, const std::array<shared_ptr<TC>,result<TC>::type::CHILDREN>& children)
>        {
>          return make_shared<typename result<TC>::type>(s,t,children);
>        }
> diff --git a/dune/typetree/powernode.hh b/dune/typetree/powernode.hh
> index 407b0cf..c4b95da 100644
> --- a/dune/typetree/powernode.hh
> +++ b/dune/typetree/powernode.hh
> @@ -5,8 +5,8 @@
>  #define DUNE_TYPETREE_POWERNODE_HH
>  
>  #include <cassert>
> +#include <array>
>  
> -#include <dune/common/array.hh>
>  #include <dune/common/typetraits.hh>
>  
>  #include <dune/typetree/nodetags.hh>
> @@ -37,7 +37,7 @@ namespace Dune {
>        }
>  
>        template<typename T, std::size_t n, typename... Args>
> -      void assign_reference_pack_to_shared_ptr_array(array<shared_ptr<T>,n>& res, Args&&... args)
> +      void assign_reference_pack_to_shared_ptr_array(std::array<shared_ptr<T>,n>& res, Args&&... args)
>        {
>          static_assert(sizeof...(Args) == n, "invalid number of arguments");
>          return assign_reference_pack_to_shared_ptr_array_unpack<T>(res.begin(),std::forward<Args>(args)...);
> @@ -57,7 +57,7 @@ namespace Dune {
>        }
>  
>        template<typename T, std::size_t n, typename... Args>
> -      void assign_shared_ptr_pack_to_shared_ptr_array(array<shared_ptr<T>,n>& res, Args&&... args)
> +      void assign_shared_ptr_pack_to_shared_ptr_array(std::array<shared_ptr<T>,n>& res, Args&&... args)
>        {
>          static_assert(sizeof...(Args) == n, "invalid number of arguments");
>          return assign_shared_ptr_pack_to_shared_ptr_array_unpack<T>(res.begin(),args...);
> @@ -117,7 +117,7 @@ namespace Dune {
>        typedef shared_ptr<const T> ChildConstStorageType;
>  
>        //! The type used for storing the children.
> -      typedef array<ChildStorageType,k> NodeStorage;
> +      typedef std::array<ChildStorageType,k> NodeStorage;
>  
>  
>        //! Access to the type and storage type of the i-th child.
> diff --git a/dune/typetree/simpletransformationdescriptors.hh b/dune/typetree/simpletransformationdescriptors.hh
> index d8e359f..b9558cd 100644
> --- a/dune/typetree/simpletransformationdescriptors.hh
> +++ b/dune/typetree/simpletransformationdescriptors.hh
> @@ -4,10 +4,11 @@
>  #ifndef DUNE_TYPETREE_SIMPLETRANSFORMATIONDESCRIPTORS_HH
>  #define DUNE_TYPETREE_SIMPLETRANSFORMATIONDESCRIPTORS_HH
>  
> +#include <array>
> +
>  #include <dune/typetree/nodetags.hh>
>  #include <dune/common/exceptions.hh>
>  #include <dune/common/shared_ptr.hh>
> -#include <dune/common/array.hh>
>  #include <dune/common/tuples.hh>
>  
>  
> @@ -55,13 +56,13 @@ namespace Dune {
>        };
>  
>        template<typename TC>
> -      static typename result<TC>::type transform(const SourceNode& s, const Transformation& t, const array<shared_ptr<TC>,result<TC>::type::CHILDREN>& children)
> +      static typename result<TC>::type transform(const SourceNode& s, const Transformation& t, const std::array<shared_ptr<TC>,result<TC>::type::CHILDREN>& children)
>        {
>          return typename result<TC>::type(children);
>        }
>  
>        template<typename TC>
> -      static typename result<TC>::storage_type transform_storage(shared_ptr<const SourceNode> s, const Transformation& t, const array<shared_ptr<TC>,result<TC>::type::CHILDREN>& children)
> +      static typename result<TC>::storage_type transform_storage(shared_ptr<const SourceNode> s, const Transformation& t, const std::array<shared_ptr<TC>,result<TC>::type::CHILDREN>& children)
>        {
>          return make_shared<typename result<TC>::type>(children);
>        }
> diff --git a/dune/typetree/transformation.hh b/dune/typetree/transformation.hh
> index 73c3640..4b6b6da 100644
> --- a/dune/typetree/transformation.hh
> +++ b/dune/typetree/transformation.hh
> @@ -4,10 +4,11 @@
>  #ifndef DUNE_TYPETREE_TRANSFORMATION_HH
>  #define DUNE_TYPETREE_TRANSFORMATION_HH
>  
> +#include <array>
> +
>  #include <dune/common/exceptions.hh>
>  #include <dune/common/typetraits.hh>
>  #include <dune/common/shared_ptr.hh>
> -#include <dune/common/array.hh>
>  #include <dune/common/tuples.hh>
>  #include <dune/typetree/typetraits.hh>
>  #include <dune/typetree/nodetags.hh>
> @@ -286,7 +287,7 @@ namespace Dune {
>          typedef TransformTree<typename S::ChildType,T,typename S::ChildType::NodeTag,ChildNodeTransformation::recursive> ChildTreeTransformation;
>          typedef typename ChildTreeTransformation::transformed_type transformed_child;
>          const std::size_t child_count = S::CHILDREN;
> -        array<shared_ptr<transformed_child>,child_count> children;
> +        std::array<shared_ptr<transformed_child>,child_count> children;
>          for (std::size_t k = 0; k < child_count; ++k) {
>            children[k] = ChildTreeTransformation::transform_storage(s.childStorage(k),t);
>          }
> @@ -300,7 +301,7 @@ namespace Dune {
>          typedef TransformTree<typename S::ChildType,T,typename S::ChildType::NodeTag,ChildNodeTransformation::recursive> ChildTreeTransformation;
>          typedef typename ChildTreeTransformation::transformed_type transformed_child;
>          const std::size_t child_count = S::CHILDREN;
> -        array<shared_ptr<transformed_child>,child_count> children;
> +        std::array<shared_ptr<transformed_child>,child_count> children;
>          for (std::size_t k = 0; k < child_count; ++k) {
>            children[k] = ChildTreeTransformation::transform_storage(s.childStorage(k),t);
>          }
> @@ -315,7 +316,7 @@ namespace Dune {
>          typedef TransformTree<typename S::ChildType,T,typename S::ChildType::NodeTag,ChildNodeTransformation::recursive> ChildTreeTransformation;
>          typedef typename ChildTreeTransformation::transformed_type transformed_child;
>          const std::size_t child_count = S::CHILDREN;
> -        array<shared_ptr<transformed_child>,child_count> children;
> +        std::array<shared_ptr<transformed_child>,child_count> children;
>          for (std::size_t k = 0; k < child_count; ++k) {
>            children[k] = ChildTreeTransformation::transform_storage(sp->childStorage(k),t);
>          }
> @@ -329,7 +330,7 @@ namespace Dune {
>          typedef TransformTree<typename S::ChildType,T,typename S::ChildType::NodeTag,ChildNodeTransformation::recursive> ChildTreeTransformation;
>          typedef typename ChildTreeTransformation::transformed_type transformed_child;
>          const std::size_t child_count = S::CHILDREN;
> -        array<shared_ptr<transformed_child>,child_count> children;
> +        std::array<shared_ptr<transformed_child>,child_count> children;
>          for (std::size_t k = 0; k < child_count; ++k) {
>            children[k] = ChildTreeTransformation::transform_storage(sp->childStorage(k),t);
>          }
> @@ -343,7 +344,7 @@ namespace Dune {
>          typedef TransformTree<typename S::ChildType,T,typename S::ChildType::NodeTag,ChildNodeTransformation::recursive> ChildTreeTransformation;
>          typedef typename ChildTreeTransformation::transformed_storage_type transformed_child_storage;
>          const std::size_t child_count = S::CHILDREN;
> -        array<transformed_child_storage,child_count> children;
> +        std::array<transformed_child_storage,child_count> children;
>          for (std::size_t k = 0; k < child_count; ++k) {
>            children[k] = ChildTreeTransformation::transform_storage(sp->childStorage(k),t);
>          }
> @@ -356,7 +357,7 @@ namespace Dune {
>          typedef TransformTree<typename S::ChildType,T,typename S::ChildType::NodeTag,ChildNodeTransformation::recursive> ChildTreeTransformation;
>          typedef typename ChildTreeTransformation::transformed_storage_type transformed_child_storage;
>          const std::size_t child_count = S::CHILDREN;
> -        array<transformed_child_storage,child_count> children;
> +        std::array<transformed_child_storage,child_count> children;
>          for (std::size_t k = 0; k < child_count; ++k) {
>            children[k] = ChildTreeTransformation::transform_storage(sp->childStorage(k),t);
>          }
> diff --git a/test/typetreetargetnodes.hh b/test/typetreetargetnodes.hh
> index 2770282..9fb598e 100644
> --- a/test/typetreetargetnodes.hh
> +++ b/test/typetreetargetnodes.hh
> @@ -32,13 +32,13 @@ struct TargetPower
>  {
>  
>    template<typename Transformation>
> -  TargetPower(const S& sc, const Transformation& t, const Dune::array<Dune::shared_ptr<T>,k>& children)
> +  TargetPower(const S& sc, const Transformation& t, const std::array<Dune::shared_ptr<T>,k>& children)
>      : Dune::TypeTree::PowerNode<T,k>(children)
>      , s(Dune::stackobject_to_shared_ptr(sc))
>    {}
>  
>    template<typename Transformation>
> -  TargetPower(Dune::shared_ptr<const S> sc, const Transformation& t, const Dune::array<Dune::shared_ptr<T>,k>& children)
> +  TargetPower(Dune::shared_ptr<const S> sc, const Transformation& t, const std::array<Dune::shared_ptr<T>,k>& children)
>      : Dune::TypeTree::PowerNode<T,k>(children)
>      , s(sc)
>    {}
> -- 
> 2.1.4
> 




> _______________________________________________
> dune-pdelab mailing list
> dune-pdelab at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune-pdelab


-- 
Prof. Dr. Christian Engwer 
Institut für Numerische und Angewandte Mathematik
Fachbereich Mathematik und Informatik der Universität Münster
Einsteinstrasse 62
48149 Münster

E-Mail	christian.engwer at uni-muenster.de
Telefon	+49 251 83-35067
FAX		+49 251 83-32729




More information about the dune-pdelab mailing list