On 07/08/2010 16:25, Blonder wrote:
Is there a difference (performance) or something else between the two solutions?
I doubt it, templates are applied at compile time in the front end of
the compiler so the generated code should be the same.
The if style syntax allows much more comprehensive
Is there a difference (performance) or something else between the two solutions?
Thanks, that is the solution.
> No programming language is intuitive; they all take time to learn.
> D is a big win over C++ though and well worth sticking with.
Yes, you are right, it takes time to learn.
@Philippe Sigaud
Thanks also.
On 06/08/2010 22:24, Blonder wrote:
Hello,
this seems to work, but if I add the following
double opBinary(string op, U) (U rhs)
{
static if(op == "^"&& is(U: Group))
{
// do something
return 42;
Hello,
this seems to work, but if I add the following
double opBinary(string op, U) (U rhs)
{
static if(op == "^" && is(U: Group))
{
// do something
return 42;
}
}
because I wa
On Fri, Aug 6, 2010 at 22:37, div0 wrote:
> Personally, I'm with you and I would expect that the compiler should
> example the function parameters after the template string parameter but it
> doesn't.
>
Yes :o(
You need to add a second template parameter for the function arguments and
add a temp
On 06/08/2010 21:37, div0 wrote:
You need to add a second template parameter for the function arguments
and add a template constrait like so:
struct Group {
int i1;
Group opBinary(string op, U) (U x)
if(op == "+" && is(U: int))
{
// do somehting
return this;
On 06/08/2010 21:08, Blonder wrote:
Hello, I am trying to understand how operator overloading works with D. I am a
C++
programmer and I am reading the book of Andrei Alexandrescu and try to
understand
D and it's language features.
My Group example don't compile, the error is:
Error: template i
Hello, I am trying to understand how operator overloading works with D. I am a
C++
programmer and I am reading the book of Andrei Alexandrescu and try to
understand
D and it's language features.
My Group example don't compile, the error is:
Error: template instance opBinary!("+") matches more th
On Friday, August 06, 2010 12:30:38 Blonder wrote:
> Hello,
>
> can someone help me with this?
>
> struct Group {
> int i1;
> Group opBinary(string op)(int x) {
> // do somehting
> return this;
> }
> Group opBinary(string op)(Group g) {
> // do something
>
Hello,
can someone help me with this?
struct Group {
int i1;
Group opBinary(string op)(int x) {
// do somehting
return this;
}
Group opBinary(string op)(Group g) {
// do something
return this;
}
}
Group g, h;
g.i1 = 1;
h = g+g;
11 matches
Mail list logo