For which types T
does
__traits(isCopyable, T)
differ from
__traits(isPOD, T)
?
Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
November 28 __traits isCopyable vs isPOD | ||||
---|---|---|---|---|
| ||||
For which types
differ from
? |
November 28 Re: __traits isCopyable vs isPOD | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On Monday, 28 November 2022 at 20:58:43 UTC, Per Nordlöw wrote: >For which types
differ from
? I'm asking because I have code like
and I wonder if one in those cases should be using |
November 28 Re: __traits isCopyable vs isPOD | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On Monday, 28 November 2022 at 20:58:43 UTC, Per Nordlöw wrote: >For which types
differ from
? Lots of types. For example, types with copy constructors or destructors are not POD but may still be copyable. This should be obvious if you read the definition of POD linked from the language spec: https://dlang.org/glossary.html#pod |
November 28 Re: __traits isCopyable vs isPOD | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Backus | On Monday, 28 November 2022 at 22:59:13 UTC, Paul Backus wrote: >Lots of types. For example, types with copy constructors or destructors are not POD but may still be copyable. This should be obvious if you read the definition of POD linked from the language spec: https://dlang.org/glossary.html#pod I guess I knew that, sorry for the dumb question - the real question I had is whether one should use
because that avoids any potential call to the copy-constructor and destructor of |
November 29 Re: __traits isCopyable vs isPOD | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On Monday, 28 November 2022 at 23:11:37 UTC, Per Nordlöw wrote: >the real question I had is whether one should use
because that avoids any potential call to the copy-constructor and destructor of If your goal is to avoid calling the copy constructor (and, I assume, to avoid unnecessary instantiations of |
November 29 Re: __traits isCopyable vs isPOD | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Backus | On Tuesday, 29 November 2022 at 00:50:54 UTC, Paul Backus wrote: >If your goal is to avoid calling the copy constructor (and, I assume, to avoid unnecessary instantiations of Thanks. |