Skip to content
Snippets Groups Projects
Commit 2fff5275 authored by Steffen Müthing's avatar Steffen Müthing
Browse files

[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.
parent 9f1a1126
Branches
Tags
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment