
On 12/14/2015 9:07 PM, Emil Dotchevski wrote:
On Mon, Dec 14, 2015 at 3:16 PM, Agustín K-ballo Bergé < kaballo86@hotmail.com> wrote:
On 12/14/2015 7:57 PM, Emil Dotchevski wrote:
On Mon, Dec 14, 2015 at 1:12 PM, Agustín K-ballo Bergé < kaballo86@hotmail.com> wrote:
On 12/14/2015 5:53 PM, Emil Dotchevski wrote:
On Mon, Dec 14, 2015 at 4:46 AM, Agustín K-ballo Bergé <
if the compiler says there is an error here because `normalized` needs a
default constructor, I'm gonna start suspecting something wrong is going
on with the library. This is what I would naively expect `normalized` to be doing:
template <typename Vec> Vec normalized(Vec v) { return v /= length(v); }
It can't be implemented that way because the type of the argument might not be copyable.
[snip]
Views are special, that has already been established. My question was not in regard of views, whose case I said is unsurprising. My question was with respect to this simple guy requiring the presence of a default constructor:
myvec3 n = normalized(myvec3(1, 2, 3));
[snip]
Why does this guy require a default constructor? I understand now that it doesn't, you simply don't want to handle this case any different than you already do views. There's nothing wrong with that.
I'm not sure if we're on the same page. I'll try again. :)
[snip]
But in the end, normalized must return an object -- and it can't use a copy constructor (different types). And since I've never encountered a vector type without a default constructor, it seemed reasonable to not worry too much about requiring it.
Yep, that sums it up. There's cases were the need for a default constructor is artificial since a copy constructor could be used, but special-casing that is not worth the trouble. Regards, -- Agustín K-ballo Bergé.- http://talesofcpp.fusionfenix.com