Allow some implicit conversions, I don't think it will hurt perf or anything.

This commit is contained in:
King_DuckZ 2020-04-08 00:01:09 +02:00
parent 2e30692071
commit eaeac13e14
2 changed files with 7 additions and 4 deletions

View file

@ -80,6 +80,9 @@ namespace vwr {
vector_type& data ( void ) { return m_wrapped; } vector_type& data ( void ) { return m_wrapped; }
const vector_type& data ( void ) const { return m_wrapped; } const vector_type& data ( void ) const { return m_wrapped; }
operator vector_type&() {return this->data();}
operator const vector_type&() const {return this->data();}
template <typename V2> template <typename V2>
const typename std::enable_if<is_vec<V2>::value and directly_convertible<V, V2>::value, V2>::type& cast ( void ) const; const typename std::enable_if<is_vec<V2>::value and directly_convertible<V, V2>::value, V2>::type& cast ( void ) const;
template <typename V2> template <typename V2>

View file

@ -231,7 +231,7 @@ namespace vwr {
Vec ( void ) = default; Vec ( void ) = default;
Vec ( const Vec& ) = default; Vec ( const Vec& ) = default;
explicit Vec ( const vector_type& parIn ) : implem::VecBase<V>(parIn) { } Vec ( const vector_type& parIn ) : implem::VecBase<V>(parIn) { }
template <typename T> template <typename T>
explicit Vec ( const typename std::enable_if<std::is_same<T, scalar_type>::value and not std::is_same<scalar_type, vector_type>::value, T>::type& parX ) : implem::VecBase<V>(parX) { } explicit Vec ( const typename std::enable_if<std::is_same<T, scalar_type>::value and not std::is_same<scalar_type, vector_type>::value, T>::type& parX ) : implem::VecBase<V>(parX) { }
#if defined(VWR_WITH_IMPLICIT_CONVERSIONS) #if defined(VWR_WITH_IMPLICIT_CONVERSIONS)
@ -259,7 +259,7 @@ namespace vwr {
Vec ( void ) = default; Vec ( void ) = default;
Vec ( const Vec& ) = default; Vec ( const Vec& ) = default;
explicit Vec ( const vector_type& parIn ) : implem::VecBase<V>(parIn) { } Vec ( const vector_type& parIn ) : implem::VecBase<V>(parIn) { }
explicit Vec ( const scalar_type parX ) : implem::VecBase<V>(parX) { } explicit Vec ( const scalar_type parX ) : implem::VecBase<V>(parX) { }
Vec ( scalar_type parX, scalar_type parY ) : implem::VecBase<V>(parX, parY) { } Vec ( scalar_type parX, scalar_type parY ) : implem::VecBase<V>(parX, parY) { }
#if defined(VWR_WITH_IMPLICIT_CONVERSIONS) #if defined(VWR_WITH_IMPLICIT_CONVERSIONS)
@ -289,7 +289,7 @@ namespace vwr {
Vec ( void ) = default; Vec ( void ) = default;
Vec ( const Vec& ) = default; Vec ( const Vec& ) = default;
explicit Vec ( const vector_type& parIn ) : implem::VecBase<V>(parIn) { } Vec ( const vector_type& parIn ) : implem::VecBase<V>(parIn) { }
explicit Vec ( const scalar_type parX ) : implem::VecBase<V>(parX) { } explicit Vec ( const scalar_type parX ) : implem::VecBase<V>(parX) { }
Vec ( scalar_type parX, scalar_type parY, scalar_type parZ ) : implem::VecBase<V>(parX, parY, parZ) { } Vec ( scalar_type parX, scalar_type parY, scalar_type parZ ) : implem::VecBase<V>(parX, parY, parZ) { }
#if defined(VWR_WITH_IMPLICIT_CONVERSIONS) #if defined(VWR_WITH_IMPLICIT_CONVERSIONS)
@ -320,7 +320,7 @@ namespace vwr {
Vec ( void ) = default; Vec ( void ) = default;
Vec ( const Vec& ) = default; Vec ( const Vec& ) = default;
explicit Vec ( const vector_type& parIn ) : implem::VecBase<V>(parIn) { } Vec ( const vector_type& parIn ) : implem::VecBase<V>(parIn) { }
explicit Vec ( const scalar_type parX ) : implem::VecBase<V>(parX) { } explicit Vec ( const scalar_type parX ) : implem::VecBase<V>(parX) { }
Vec ( scalar_type parX, scalar_type parY, scalar_type parZ, scalar_type parW ) : implem::VecBase<V>(parX, parY, parZ, parW) { } Vec ( scalar_type parX, scalar_type parY, scalar_type parZ, scalar_type parW ) : implem::VecBase<V>(parX, parY, parZ, parW) { }
#if defined(VWR_WITH_IMPLICIT_CONVERSIONS) #if defined(VWR_WITH_IMPLICIT_CONVERSIONS)