← Top stories In C++, = default and {} are not the same constructor ↗ (opens external site) 129 points by surprisetalk 2 days ago | lemire.me | 198 comments on HN ↗ View full thread · View on Hacker News Comment thread (5) layer8 | 2 days ago | parent | reply Rust doesn’t have implementation inheritance. If it did, it would need a constructor-like concept as well. Replies (1) gpderetta | 2 days ago | parent | reply With guaranteed RVO you could do something like this (pseudo-C): struct FooBase { ... } fn make_foo_base(...) -> FooBase struct Foo { base : FooBase; ... } fn make_foo(args...) -> Foo { return { .base = make_foo_base(...), ... } } Replies (1) layer8 | 2 days ago | parent | reply How is it ensured that make_foo will actually call make_foo_base? Replies (2) gpderetta | 2 days ago | parent | reply You are right, sorry, lost track or the thread. edflsafoiewq | 1 day ago | parent | reply Because it needs a FooBase to give as the value for .base or the struct initialization isn't valid because it doesn't give values for all the members?
Replies (1)
Replies (1)
Replies (2)