explicit Exception copy constructor#2613
Conversation
|
Can we remove the copy constructor entirely and add a |
I updated Is there a specific reason you'd prefer clone rather than explicit copy constructor + kj::cp(e) for brevity? |
Exception is very heavy object, implicit copy constructor is probably an oversight.
e845be1 to
ae2563a
Compare
|
btw |
|
Explicit constructors don't really work. Consider what happens if you have: kj::Vector<Exception> vec;
kj::Exception e;
vec.add(e);You want this to fail, because add() is invoking the copy consturctor. But template <typename... Params>
T& add(Params&&... params) KJ_LIFETIMEBOUND {
KJ_IREQUIRE(pos < endPtr, "Added too many elements to ArrayBuilder.");
ctor(*pos, kj::fwd<Params>(params)...);
return *pos++;
}That
The use of |
|
I see your point. It will be a bit more involved but I think we can pull it off. I will do it in two steps then: I'll add .clone() method, will migrate all downstream and then will completely remove copy constructor. |
Exception is very heavy object, implicit copy constructor is probably an oversight.