Commit 700d8d83 authored by Oliver Sander's avatar Oliver Sander

For consistency: add constructor from std::initializer_list to FieldVector<.,1>

parent b1e924e6
......@@ -255,6 +255,13 @@ namespace Dune {
: Base(), _data( other._data )
{}
/** \brief Construct from a std::initializer_list */
FieldVector (std::initializer_list<K> const &l)
{
assert(l.size() == 1);
_data = *l.begin();
}
//! Assignment operator for scalar
template<typename T,
typename EnableIf = typename std::enable_if<
......
  • Actually, the line

    Dune::FieldVector<double, 1> v = {1};

    from dune/common/test/boundscheckingtest.cc worked just fine even without this change...

    Edited by Elias Pipping
  • Yes, but

    Dune::FieldVector<std::complex,1> v = {{1,0}};

    didn't.

  • True. Now all of these work as expected:

      Dune::FieldMatrix<std::complex<double>, 1, 1> x = {1};
      Dune::FieldMatrix<std::complex<double>, 1, 1> y = {{1, 1}};
      Dune::FieldVector<std::complex<double>, 1> w = {1};
      Dune::FieldVector<std::complex<double>, 1> v = {{1, 1}};

    Great!

Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment