Skip to content

Commit a666cf4

Browse files
authored
Merge pull request #264 from JM1/master
Fix ambiguous template special. errors with GCC 7+
2 parents ed91bc4 + f3ede00 commit a666cf4

File tree

3 files changed

+161
-141
lines changed

3 files changed

+161
-141
lines changed

include/El/blas_like/level1/decl.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ void Contract( const BlockMatrix<T>& A, BlockMatrix<T>& B );
487487
template<typename T>
488488
void Copy( const Matrix<T>& A, Matrix<T>& B );
489489
template<typename S,typename T,
490-
typename=EnableIf<CanCast<S,T>>>
490+
typename=EnableIf<And< CanCast<S,T>, Not<IsSame<S,T>> >>>
491491
void Copy( const Matrix<S>& A, Matrix<T>& B );
492492

493493
template<typename S,typename T,
@@ -501,7 +501,7 @@ void Copy( const BlockMatrix<S>& A, BlockMatrix<T>& B );
501501
template<typename T>
502502
void Copy( const AbstractDistMatrix<T>& A, AbstractDistMatrix<T>& B );
503503
template<typename S,typename T,
504-
typename=EnableIf<CanCast<S,T>>>
504+
typename=EnableIf<And< CanCast<S,T>, Not<IsSame<S,T>> >>>
505505
void Copy( const AbstractDistMatrix<S>& A, AbstractDistMatrix<T>& B );
506506

507507
template<typename T>
@@ -532,7 +532,7 @@ template<typename T>
532532
void Copy( const SparseMatrix<T>& A, SparseMatrix<T>& B );
533533

534534
template<typename S,typename T,
535-
typename=EnableIf<CanCast<S,T>>>
535+
typename=EnableIf<And< CanCast<S,T>, Not<IsSame<S,T>> >> >
536536
void Copy( const SparseMatrix<S>& A, SparseMatrix<T>& B );
537537

538538
template<typename S,typename T,
@@ -543,7 +543,7 @@ template<typename T>
543543
void Copy( const DistSparseMatrix<T>& A, DistSparseMatrix<T>& B );
544544

545545
template<typename S,typename T,
546-
typename=EnableIf<CanCast<S,T>>>
546+
typename=EnableIf<And<CanCast<S,T>,Not<IsSame<S,T>>>>>
547547
void Copy( const DistSparseMatrix<S>& A, DistSparseMatrix<T>& B );
548548

549549
template<typename S,typename T,
@@ -559,7 +559,7 @@ template<typename T>
559559
void Copy( const DistMultiVec<T>& A, DistMultiVec<T>& B );
560560

561561
template<typename S,typename T,
562-
typename=EnableIf<CanCast<S,T>>>
562+
typename=EnableIf< And< CanCast<S,T>, Not<IsSame<S,T>> > >>
563563
void Copy( const DistMultiVec<S>& A, DistMultiVec<T>& B );
564564

565565
template<typename T>

include/El/core.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ enum FortranLogicalEnum
102102
template<typename S,typename T>
103103
using IsSame = std::is_same<S,T>;
104104

105+
template<typename S, typename T>
106+
struct And {
107+
static constexpr bool value = S::value && T::value;
108+
};
109+
110+
template<typename T>
111+
struct Not {
112+
static constexpr bool value = !T::value;
113+
};
114+
105115
template<typename Condition,class T=void>
106116
using EnableIf = typename std::enable_if<Condition::value,T>::type;
107117
template<typename Condition,class T=void>

0 commit comments

Comments
 (0)