Re: Exec function D from C++

2015-06-21 Thread Jacob Carlborg via Digitalmars-d-learn
On 21/06/15 16:09, Sean Campbell wrote: extern(C++) void d_initialize() { Runtime.initialize(); } extern(C++) void d_terminate() { Runtime.terminate(); } These two functions are not necessary. There are already functions in druntime which are supposed to be called from C/C++:

Re: Passing functions as template parameter and assigning default values to them

2015-06-21 Thread kerdemdemir via Digitalmars-d-learn
On Sunday, 21 June 2015 at 10:06:15 UTC, biozic wrote: You can use a template alias parameter with a default value that is your default lambda: int indexOfMax(alias fun = a = a, R)(R range) { // Use `fun` here like a function. } -- Nico Thanks a lot, it works !!

Re: Exec function D from C++

2015-06-21 Thread Sean Campbell via Digitalmars-d-learn
On Sunday, 21 June 2015 at 13:12:03 UTC, MGW wrote: Linux 32, dmd 2.067.0 I want to connect and execute function D from main() C++. d1.d import core.stdc.stdio; extern (C++) void d1() { printf(printf - exec d1()); } main_c1.cpp #include stdio.h void d1(void); int

Exec function D from C++

2015-06-21 Thread MGW via Digitalmars-d-learn
Linux 32, dmd 2.067.0 I want to connect and execute function D from main() C++. d1.d import core.stdc.stdio; extern (C++) void d1() { printf(printf - exec d1()); } main_c1.cpp #include stdio.h void d1(void); int main(void) { d1(); return 0; } compile

type of a variable as a mixin-able string?

2015-06-21 Thread Timothee Cour via Digitalmars-d-learn
Suppose I have: import std.range; auto a=iota(complex_expr_returning_3()); I'd like to have a function/trait/template/compiler magic that takes variable a and generates a string that can be mixed in to represent the type of a. The difficulty is that typeid(a).to!string doesn't work for

Re: pass by value elide dtor + post-blit

2015-06-21 Thread Xiaoxi via Digitalmars-d-learn
On Saturday, 20 June 2015 at 22:44:17 UTC, Ali Çehreli wrote: On 06/20/2015 02:09 PM, Xiaoxi wrote: The output: before deneme.S.this after deneme.S.~this Ali Dear Ali, thank you for helping! Problem happens when passing by value as in param. DMD32 D Compiler v2.067.0 deneme.S.this before

Re: pass by value elide dtor + post-blit

2015-06-21 Thread Namespace via Digitalmars-d-learn
Dear Ali, thank you for helping! Problem happens when passing by value as in param. Change 'foo' to this: ref S foo(ref S s) { s.val+=1; return s; }

Passing functions as template parameter and assigning default values to them

2015-06-21 Thread kerdemdemir via Digitalmars-d-learn
Hi, I need to find the index of maximum element so my code: int indexOfMax(R)(R range) { alias Type = typeof(range.front().re); I don't like .re here Type max = 0; size_t maxIndex = 0; foreach ( index,elem; range ) { if ( elem.re max )- And

Re: Passing functions as template parameter and assigning default values to them

2015-06-21 Thread biozic via Digitalmars-d-learn
On Sunday, 21 June 2015 at 09:34:51 UTC, kerdemdemir wrote: Hi, I need to find the index of maximum element so my code: int indexOfMax(R)(R range) { alias Type = typeof(range.front().re); I don't like .re here Type max = 0; size_t maxIndex = 0; foreach (