is Dlang support Uniform initialization like c++

Steven Schveighoffer schveiguy at gmail.com
Fri Jun 30 15:54:58 UTC 2023


On 6/30/23 11:18 AM, lili wrote:
>      struct Point {
>       int x;
>       int y;
>        this(int x, int y) { this.x =x; this.y=y;}
>      }
> 
>      void addPoint(Point a, Point b) {
>         ...
>      }
> 
> How too wirte this: addPoint({4,5}, {4,6})

You have to write `Point(4, 5)`. The advantage is we don't need to deal 
with the complexity of C++ overloading rules.

-Steve


More information about the Digitalmars-d-learn mailing list