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

Dune flyspray at dune-project.org
Mon Jan 23 14:59:56 CET 2012


THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.

The following task has a new comment added:

FS#1024 - Constructor call DiagonalMatrix<K,n>::DiagonalMatrix(FieldVector<K,1>) ambiguous for n>2
User who did this - Jö Fahlke (joe)

----------
With the old patch, our code looked like this:
==================================================
  template<class C>
     FieldVector (const DenseVector<typename Dune::enable_if<IsFieldVectorSizeCorrect<C,SIZE>::value,C>::type > & x)
==================================================
Basically, you're telling the compiler: look, I'm calling a constructor with an argument of type U, please determine C such that U can be converted to DenseVector<typename Dune::enable_if<IsFieldVectorSizeCorrect<C,SIZE>::value,C>::type>.  This is of course much to complicated for the compiler to do, and in general it may even be not unique.

Your new code looks like this:
==================================================
  template<class C>
     FieldVector (const DenseVector<C> & x, typename Dune::enable_if<IsFieldVectorSizeCorrect<C,SIZE>::value>::type* dummy=0 )
==================================================
Here, it is possible for the compiler to deduce the template argument C from the type of x; if x is of type [const] DenseVector<U> [&] then C is U.  When the compiler considers the dummy argument, it has already deduced C, and can simply evaluate the template expression.  If evaluating the template expression fails, the constructor is remove from the overload set for the constructor call under consideration.

I think deduction is also possible in some more involved cases (like when x can be converted to DenseVector<U> and there exists no other type U2!=U such that x can be converted to DenseVector<U2>) but I would have to read the standard for the details.
----------

More information can be found at the following URL:
http://www.dune-project.org/flyspray/index.php?do=details&task_id=1024#comment3071

You are receiving this message because you have requested it from the Flyspray bugtracking system.  If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.




More information about the Dune mailing list