__traits isCopyable vs isPOD

Per Nordlöw per.nordlow at gmail.com
Mon Nov 28 23:11:37 UTC 2022


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 `isPOD` instead of 
`isCopyable` in cases

```d
             static if (__traits(isCopyable, Element))
                 insertAt(element, index);
             else
                 insertAt(move(element), index);
```

because that avoids any potential call to the copy-constructor 
and destructor of `Element`. Afaict, one should.


More information about the Digitalmars-d-learn mailing list