Skip to content

#1024 Constructor call DiagonalMatrix<K,n>::DiagonalMatrix(FieldVector<K,1>) ambiguous for n>2

Metadata

Property Value
Reported by Uli Sack (usack@math.fu-berlin.de)
Reported at Jan 19, 2012 13:51
Type Bug Report
Version Git (pre2.4) [autotools]
Operating System Unspecified / All
Last edited by Carsten Gräser (graeser@math.fu-berlin.de)
Last edited at May 2, 2012 14:45
Closed by Carsten Gräser (graeser@math.fu-berlin.de)
Closed at May 2, 2012 14:45
Closed in version Unknown
Resolution Fixed
Comment Fixed in dune-common r6680.

Description

DiagonalMatrix has two relevant Constructors here: //! Constructor initializing the whole matrix with a scalar DiagonalMatrix (const K& k) : diag_(k) {}

//! Constructor initializing the diagonal with a vector
DiagonalMatrix (const FieldVector<K,n>& diag)
    : diag_(diag)
{}

I would expect due to the conversion FieldVector<K,1>::operator K() that the first constructor would be called, since FieldVector<K,1> on first sight doesn't match the signature of the second. But owing to implicit type conversion and the constructor FieldVector<K,n>::template FieldVector (const DenseVector & x) it actually does. The compiler doesn't care that the static_assertion will fail anyway.

A possible way to fix this behavior would be to make the named Constructor in FieldVector explicit just as its close relative is: template<class K1, int SIZE1> explicit FieldVector (const FieldVector<K1,SIZE1> & x)

So my question is, if there is a necessity for the first mentioned FieldVector-constructor to not be explicit. If the answer is no I request it to be made explicit.