Skip to content
Snippets Groups Projects
Commit 9d46150e authored by Christian Engwer's avatar Christian Engwer
Browse files

[fieldvector] add constructors for scalar fieldvector, matching all compatible scalar data types

in order to make GMPField work in more situations, we add a constrctor, which matches
all scalar data types, which can me converted to K.
We deliberately exclude K from the template match.
parent 7135cbb0
No related branches found
No related tags found
No related merge requests found
......@@ -228,7 +228,14 @@ namespace Dune {
{}
/** \brief Constructor with a given scalar */
FieldVector (const K& k) : _data(k) {}
template<typename T,
typename EnableIf = typename std::enable_if<
std::is_convertible<T, K>::value &&
! std::is_same<K, DenseVector<typename FieldTraits<T>::field_type>
>::value
>::type
>
FieldVector (const T& k) : _data(k) {}
//! Constructor making vector with identical coordinates
template<class C>
......@@ -245,7 +252,14 @@ namespace Dune {
{}
//! Assignment operator for scalar
inline FieldVector& operator= (const K& k)
template<typename T,
typename EnableIf = typename std::enable_if<
std::is_convertible<T, K>::value &&
! std::is_same<K, DenseVector<typename FieldTraits<T>::field_type>
>::value
>::type
>
inline FieldVector& operator= (const T& k)
{
_data = k;
return *this;
......
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