How do i depend on struct composition

Mariusz `shd` Gliwiński" <alienballance at gmail.com> Mariusz `shd` Gliwiński" <alienballance at gmail.com>
Thu Aug 22 14:07:26 PDT 2013


Let me try to illustrate my question by following pseudo-code:

struct InnerA
{
   /* .. */
   void* ptr;
}
struct InnerB
{
   /* .. */
   void* ptr;
}
struct InnerC
{
   void operate()
   {
     auto ptr = this-(void*).sizeof;
     /* do something with pointer */
   }
}

struct Compound(Inner)
{
   Inner  a_or_b;
   InnerC c;
}

I need to pass "c" to some subsystem which shouldn't be aware of 
"a_or_b"

However, subsystem should be able to call function 
InnerB.operate() which needs access to "a_or_b".

Now my questions:
* Is there any way to tell subsystem, that he can't instantiate 
nor move InnerC
* Is there any better,platform-independent way of accessing 
pointer from struct a_or_b ?

Thanks in advance,
Mariusz


More information about the Digitalmars-d-learn mailing list