[Issue 5710] cannot use delegates as parameters to non-global template

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 7 05:52:47 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=5710



--- Comment #24 from Steven Schveighoffer <schveiguy at yahoo.com> 2013-05-07 05:52:41 PDT ---
(In reply to comment #23)
> 
> No, because you can call the same template instantiation with different "this"
> pointers even though the "alias" parameter is the same. Each "this" pointer
> will be at a different location in the stack frame, so "foo" can't possibly
> know which one to use.

Yes, you are right, thanks for explaining.

> With Kenji's idea, you have 2 pointers on the stack:
> 
> struct multi_context {
>     stack_frame* base_ptr; // pointer to start of stack frame
>     T* this_ptr; // pointer 
> }
> 
> struct stack_frame {
>     // other stuff
>     multi_context context;
> }
> 
> "foo" is called by passing in a pointer to the "multi_context" struct from
> which both the "this_ptr" and "base_ptr" can be obtained.

Likely the this_ptr is repeated inside the stack frame for normal access during
the function.

Anyway, the point is moot since only Kenji's solution is valid.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list