Skip to content
Snippets Groups Projects
Commit 5e1bdf93 authored by Christian Engwer's avatar Christian Engwer Committed by Carsten Gräser
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.

(cherry picked from commit 9d46150e)
Signed-off-by: default avatarCarsten Gräser <graeser@dune-project.org>
parent c9b21320
No related branches found
No related tags found
1 merge request!2512017-05 merge of upstream repository
......@@ -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