Bug 3852 – Default struct constructors needed

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-02-25T02:19:18Z
Last change time
2019-11-07T08:07:45Z
Assigned to
No Owner
Creator
Max Samukha

Comments

Comment #0 by samukha — 2010-02-25T02:19:18Z
Qt has quite a lot of types with pass-by-value semantics. For example, all COW types are value types (http://doc.trolltech.com/4.6/shared.html#list-of-classes). Currently, QtD implements such types as classes, which implies an excessive heap allocation happens every time a value of such a type is passed to D. We are trying to solve this problem by wrapping Qt's value types in D structs. Those structs must always be properly initialized via a call to Qt. It would be incorrect to just declare a variable like this: QString s; We would have to force the programmer to explicitly run a function emulating the default constructor (e.g. opCall), or expect him to suffer badly when he forgets to do so. Possible solutions: 1. Implement proper default constructors for structs. 2. Make it possible to forbid the use of uninitialized structs.
Comment #1 by yebblies — 2014-02-28T04:51:14Z
*** Issue 12252 has been marked as a duplicate of this issue. ***
Comment #2 by razvan.nitu1305 — 2019-11-06T14:55:41Z
How come disbling the default constructor via `disable this();` does not solve your issues? I am tempted to close this as WONTFIX as the board is probably going to be against adding the possibility of defining default constructors.
Comment #3 by maxsamukha — 2019-11-07T08:05:57Z
(In reply to RazvanN from comment #2) > How come disbling the default constructor via `disable this();` does not > solve your issues? > > I am tempted to close this as WONTFIX as the board is probably going to be > against adding the possibility of defining default constructors. There was no @disabled at the time the bug was reported.