Re: [eigen] Can we prevent that this compiles? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
Hi
On Wednesday 30 September 2009 16:29:51 Hauke Heibel wrote:
> I think I prefer the second solution. It's less hassle... there were even a
> third solution when it were possible to take the Matrix ctors explicit. But
> there I think we rely on the implicit conversion.
Hm, what was the third solution?
Also, what solution do you refer to as the second solution? For me, the first
is the additional user-defined conversion to ConstRef, the second is the
template constructor.
The reason why I like the first solution better is that it does not add any
constructors. There's one major benefit, consider:
Replicate<MatrixXd::RowXpr,2,1> rep(5);
Here, the compiler won't find a suitable constructor and will probably list
the set of candidates. That might be very helpful. With the second approach, a
suitable constructor *is* found, but instantiation leads to an unusual compile
error. (The templated constructor could be restricted to types that are
actually convertible to T (sfinae, boost::enable_if-like), but that would be a
real mess in my opinion)
Markus
--
PGP key on www.esat.kuleuven.be/~mmoll/public_key.pgp
Fingerprint is
90C4 B47D 1A00 5AC1 9147 3197 EDA7 1E0E 99E4 9EDB