Why are opCall's not implicitely assignable?
nobody
nobody at mailinator.com
Fri Sep 22 13:31:41 PDT 2006
Karen Lanrap wrote:
> The answer is easy: the opCall for a reference of its own class
> should be disallowed.
...
> That is also easy: no qwert can have its own type as a single
> parameter. Otherwise show me an example.
I believe the original intention of opCall was to allow constructor (ctor) like
behavior for structs which have no ctors. Given that origin I think you will
find that if an opCall is defined it is in fact normal for it to have an
overload which is its own type as a single parameter:
struct Point
{
private:
int x, y;
public:
/// Create a Point object given coords x and y
Point* opCall(int x, int y) { /* ... */ }
/// Create a Point object given another Point
Point* opCall(Point p) { /* ... */ }
}
More information about the Digitalmars-d-learn
mailing list