[Dune-devel] [Dune-Commit] [Commit] dune-common - 2fff527: [Release][Array] Provide a function for creating an array filled with copies of a single element

Oliver Sander sander at igpm.rwth-aachen.de
Mon Dec 16 17:07:21 CET 2013


Hi Steffen,
I suppose the line

> +    std::cout << "test" << std::endl;

is not there to stay?

Why do I need this method anyway, when I have std::fill?

Is it going to go away when we kill our own array implementation?

Cheers,
Oliver

Am 16.12.2013 17:04, schrieb Steffen Müthing:
> New commit, appeared at Mon Dec 16 17:04:40 2013 +0100
> as part of the following ref changes:
> 
>     branch refs/heads/master    updated from 9f1a112 -> 2fff527
> 
> Browsable version: http://cgit.dune-project.org/repositories/dune-common/commit/?id=2fff527599173a8da0ce38a7c9d7f38053f04122
> 
> ======================================================================
> 
> commit 2fff527599173a8da0ce38a7c9d7f38053f04122
> Author: Steffen Müthing <muething at dune-project.org>
> Date:   Mon Dec 16 17:02:12 2013 +0100
> 
>     [Release][Array] Provide a function for creating an array filled with copies of a single element
>     
>     The new YaspGrid constructors require an array with the number of cells
>     in each direction. Unfortunately, there is no array constructor that
>     takes a single element and copies it to all array elements.
>     
>     This patch adds a simple function Dune::fill_array() to do just that.
> 
>  dune/common/array.hh | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> 
> 
> diff --git a/dune/common/array.hh b/dune/common/array.hh
> index cf2cf3a..5b550d3 100644
> --- a/dune/common/array.hh
> +++ b/dune/common/array.hh
> @@ -253,6 +253,23 @@ namespace Dune
>      return result;
>    }
>  
> +  //! Create an array and fill it with copies of the provided value.
> +  /**
> +   * \note This method is Dune-specific and not part of any C++ standard.
> +   */
> +  template<typename T, std::size_t n>
> +  array<T,n> fill_array(const T& t)
> +  {
> +    array<T,n> r;
> +    r.fill(t);
> +    std::cout << "test" << std::endl;
> +#if HAVE_RVALUE_REFERENCES
> +    return std::move(r);
> +#else
> +    return r;
> +#endif
> +  }
> +
>    /** @} */
>  
>  } // end namespace Dune
> 
> _______________________________________________
> Dune-Commit mailing list
> Dune-Commit at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune-commit
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 551 bytes
Desc: OpenPGP digital signature
URL: <https://lists.dune-project.org/pipermail/dune-devel/attachments/20131216/185aa518/attachment.sig>


More information about the Dune-devel mailing list