Skip to content

Commit

Permalink
Fix an issue with ambiguous operators caused by implicit constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonCampolattaro committed Oct 26, 2023
1 parent 5831dd2 commit 3505de9
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions include/symtensor/SymmetricTensorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,19 @@ namespace symtensor {
*
* @param s a sequence of scalar values to initialize the tensor.
*/
constexpr SymmetricTensorBase(auto ...s) : _data{static_cast<S>(s)...} {
explicit constexpr SymmetricTensorBase(auto ...s) : _data{static_cast<S>(s)...} {
static_assert(sizeof...(s) == NumUniqueValues);
}

// todo: this might perform better in some cases
// constexpr SymmetricTensorBase(std::initializer_list<Scalar> scalars) {
// assert(scalars.size() == NumUniqueValues);
// std::copy(scalars.begin(), scalars.end(), _data.begin());
// }
/**
* @brief (Implicit) constructor from a sequence of values.
*
* @param s a sequence of scalar values to initialize the tensor.
*/
constexpr SymmetricTensorBase(std::initializer_list<Scalar> scalars) {
assert(scalars.size() == NumUniqueValues);
std::copy(scalars.begin(), scalars.end(), _data.begin());
}

constexpr Self &operator=(const Self &other) = default;

Expand Down Expand Up @@ -542,8 +546,9 @@ namespace symtensor {
/// @{

template<symmetric_tensor<D, I> OtherTensor>
friend auto operator*(
const Implementation &lhs,
requires requires { OtherTensor::Rank; }
inline friend auto operator*(
const Self &lhs,
const OtherTensor &rhs
) {

Expand Down

0 comments on commit 3505de9

Please sign in to comment.