Skip to content
Snippets Groups Projects
Commit b351862d authored by Carsten Gräser's avatar Carsten Gräser
Browse files

Remove constructor for FV<K1,n> from FV<K2,m> with n!=m

This patch removes the constructor from the overload set.
Before the constructor was there but failed to compile
due to the static assertion.

If you have methods f(K) and f(FieldVector<K,n>) with
n>1 the overload was ambigous when calling f() with
a FieldVector<K,1> because there is a conversion
from this to FieldVector<K,n> - even if it does not
compile due to the failing static assertion.

Now this is avoided using SFINAE. This fixes fs#1024. 

[[Imported from SVN: r6680]]
parent 6805fc0c
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@
#include <complex>
#include <cstring>
#include "typetraits.hh"
#include "exceptions.hh"
#include "array.hh"
#include "densevector.hh"
......@@ -124,9 +125,19 @@ namespace Dune {
FieldVector (const FieldVector & x) : _data(x._data)
{}
//! Constructor making vector with identical coordinates
/**
* \brief Constructor making vector with identical coordinates
*
* If the DenseVector type of the this constructors argument
* is impemented by a FieldVector, it is statically checked
* if it has the correct size. If this is not the case
* the constructor is removed from the overload set using SFINAE.
*
* \param[in] x A DenseVector with correct size.
* \param[in] dummy A void* dummy argument needed by SFINAE.
*/
template<class C>
FieldVector (const DenseVector<C> & x)
FieldVector (const DenseVector<C> & x, typename Dune::enable_if<IsFieldVectorSizeCorrect<C,SIZE>::value>::type* dummy=0 )
{
dune_static_assert(((bool)IsFieldVectorSizeCorrect<C,SIZE>::value), "FieldVectors do not match in dimension!");
assert(x.size() == SIZE);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment