reference <op> reference is ambiguous
Closed this issue · 2 comments
datapar<int> x = ...;
x[0] + x[0]; // ambiguous!
That's because x[0] is directly convertible to datapar<int>
via the broadcast constructor. Thus, the builtin int + int
operator (after conversion via reference::operator value_type() const
is equally viable as friend datapar operator+(const datapar &, const datapar &)
(at least GCC and ICC say so). Removing the broadcast ctor would make me unhappy:
x + x[0]; // implicit broadcast of the RHS; would be ill-formed
The alternative resolution requires overloads of the binary operators of the reference
type. I'll add this resolution to the paper (and implemented the solution in my implementation). If you see a problem with this, please speak up.
The two user-defined conversion choices are what, here?
"datapar<T>::reference
converts to T" and "datapar<T>
constructor taking a datapar<T>::reference
"?
Yes. The datapar
broadcast ctor looks like this currently:
Thus it can directly convert from datapar::reference
, which is implicitly convertible to value_type
via its operator value_type() const
.
Note that I modified the signature to datapar(U &&)
in my implementation to resolve #30.