On Saturday, 24 June 2017 at 21:41:22 UTC, Moritz Maxeiner wrote:
Hi, unfortunately not:
- Operator overloading is supported via member functions only
[1].
- Corollary: You cannot overload operators for builtin types
(i.e. where the cast gets rewritten to `e.opOverloaded` where
`e` is a
On Saturday, 24 June 2017 at 21:11:13 UTC, Igor Shirkalin wrote:
Is it possible without such a constructor?
No. Also, the above works because of the following [1]:
Casting a value v to a struct S, when value is not a struct of
the same type, is equivalent to: `S(v)`
[1]
On Saturday, 24 June 2017 at 20:43:48 UTC, Igor Shirkalin wrote:
I'm in trouble with opCast function.
Is it possible to cast some (integral) type to user defined
structure?
Hi, unfortunately not:
- Operator overloading is supported via member functions only [1].
- Corollary: You cannot
On Saturday, 24 June 2017 at 20:43:48 UTC, Igor Shirkalin wrote:
struct A
{
void * data; // void * type is just for example
// no matter what is here
}
I know that if I add constructor this(int)
struct A {
void * p;
this(int k) { p = cast(void*)k; }
}
auto a = cast(A)
Hello!
I'm in trouble with opCast function.
Is it possible to cast some (integral) type to user defined
structure?
We have a structure:
struct A
{
void * data; // void * type is just for example
// no matter what is here
}
How can we define opCast operator to make the following