File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ constexpr MatrixBase<TMA>::MatrixBase(T_element... vaElements) :
1616
1717
1818template <TMP >
19- constexpr MatrixBase<TMA >::MatrixBase(T_number aSingleElement) :
19+ constexpr MatrixBase<TMA >::MatrixBase(T_number aSingleElement) requires (N_rows*N_cols == 1 ) :
2020 mStore { {aSingleElement} }
2121{}
2222
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ class MatrixBase
134134 { setZero (); }
135135
136136 // Implementer note:
137- // I don't feel confident enought with my understanding of aggregate initialization
137+ // I don't feel confident enough with my understanding of aggregate initialization
138138 // (see: https://en.cppreference.com/w/cpp/language/aggregate_initialization)
139139 // to know when it can and cannot throw exceptions. So be conservative and noexcept(false).
140140 //
@@ -157,9 +157,12 @@ class MatrixBase
157157 std::enable_if_t <sizeof ...(T_element) == N_rows*N_cols && (N_rows*N_cols > 1 ), int > = 0 >
158158 constexpr MatrixBase (T_element... vaElements) /* noexcept (see note)*/ ;
159159
160- // Note: split because of a complication with explicit handling
160+ // Note: split because of a complication with explicit handling of the ctor above (see comments).
161161 // (C++ 20 introduce conditional explicit, which could be used instead)
162- constexpr explicit MatrixBase (T_number aSingleElement) /* noexcept (see note)*/ ;
162+ // This constructor is restricted to the case where the matrix is 1 element exactly.
163+ // Note: Without `requires` clause, one could rely on SFINAE, by templating the method with
164+ // <typename = std::enable_if_t<(N_rows*N_cols == 1)>>
165+ constexpr explicit MatrixBase (T_number aSingleElement) requires (N_rows*N_cols == 1 ) /* noexcept (see note)*/ ;
163166
164167 // / \brief Explicit cast to another derived type of same dimensions and scalar type
165168 template <class T_otherDerived ,
You can’t perform that action at this time.
0 commit comments