Re: How to create friends of a class at compile time?

2021-07-15 Thread Ali Çehreli via Digitalmars-d-learn
On 7/15/21 5:46 PM, Ali Çehreli wrote: > On 7/15/21 11:24 AM, Tejas wrote: > > package(qualifiedIdentifier) > Just don't do it Ok, I said all that before realizing what you needed with transpiling C++ to D and the solution of package(qualifiedIdentifier). (And package(qualifiedIdentifier) i

Re: How to create friends of a class at compile time?

2021-07-15 Thread Ali Çehreli via Digitalmars-d-learn
On 7/15/21 11:24 AM, Tejas wrote: > it seems like seperating chunks of C++ code into seperate modules > and using the > ```d > package(qualifiedIdentifier) > ``` > access specifier seems to be the way to go. That would be necessary if one agreed with C++'s 'private' to begin with. In other word

Re: How to create friends of a class at compile time?

2021-07-15 Thread Tejas via Digitalmars-d-learn
On Thursday, 15 July 2021 at 18:06:26 UTC, Steven Schveighoffer wrote: On 7/15/21 1:43 PM, Tejas wrote: How do you write the equivalent of that in D? Is the answer still the same? Manually keep it in the same module, or is there a programmatic way of converting this to D? Functions in the sa

Re: How to create friends of a class at compile time?

2021-07-15 Thread Tejas via Digitalmars-d-learn
On Thursday, 15 July 2021 at 18:11:30 UTC, evilrat wrote: On Thursday, 15 July 2021 at 17:49:06 UTC, Tejas wrote: I'm sorry, I should've explicitly mentioned I'm interested in learning how to do friend injection in D. I know that access specifiers operate at module scope, seen a few posts

Re: How to create friends of a class at compile time?

2021-07-15 Thread evilrat via Digitalmars-d-learn
On Thursday, 15 July 2021 at 17:49:06 UTC, Tejas wrote: I'm sorry, I should've explicitly mentioned I'm interested in learning how to do friend injection in D. I know that access specifiers operate at module scope, seen a few posts about that here already. Thank you for answering though.

Re: How to create friends of a class at compile time?

2021-07-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/15/21 1:43 PM, Tejas wrote: How do you write the equivalent of that in D? Is the answer still the same? Manually keep it in the same module, or is there a programmatic way of converting this to D? Functions in the same module can access `private` members. Functions in the same package (

Re: How to create friends of a class at compile time?

2021-07-15 Thread Tejas via Digitalmars-d-learn
On Thursday, 15 July 2021 at 17:30:05 UTC, jfondren wrote: On Thursday, 15 July 2021 at 17:21:45 UTC, Tejas wrote: I can do it like this in C++: ``` template class def { friend typename abc; } ``` I am just hopelessly confused on how to achieve the same in D. Uncharitably: D is a friendle

Re: How to create friends of a class at compile time?

2021-07-15 Thread Tejas via Digitalmars-d-learn
If, however, you're trying to inject friend access to something outside def's module, then you might want to reconsider what you're trying to accomplish and whether it can be done differently. Was just dreaming of how to transpile C++ code to D :( Curiously enough, friend injection w

Re: How to create friends of a class at compile time?

2021-07-15 Thread Tejas via Digitalmars-d-learn
On Thursday, 15 July 2021 at 17:26:41 UTC, Adam D Ruppe wrote: On Thursday, 15 July 2021 at 17:21:45 UTC, Tejas wrote: I can do it like this in C++: You don't just put class def and class abc in the same module and you get the same effect though. I really should've just posted the whole thi

Re: How to create friends of a class at compile time?

2021-07-15 Thread jfondren via Digitalmars-d-learn
On Thursday, 15 July 2021 at 17:21:45 UTC, Tejas wrote: I can do it like this in C++: ``` template class def { friend typename abc; } ``` I am just hopelessly confused on how to achieve the same in D. Uncharitably: D is a friendless language. Charitably: D is so much more friendly that in

Re: How to create friends of a class at compile time?

2021-07-15 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jul 15, 2021 at 05:21:45PM +, Tejas via Digitalmars-d-learn wrote: > I can do it like this in C++: > ``` > template > class def > { > friend typename abc; > } > ``` > > I am just hopelessly confused on how to achieve the same in D. D does not have `friend` declarations. Equivalent

Re: How to create friends of a class at compile time?

2021-07-15 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 15 July 2021 at 17:21:45 UTC, Tejas wrote: I can do it like this in C++: You don't just put class def and class abc in the same module and you get the same effect though.

How to create friends of a class at compile time?

2021-07-15 Thread Tejas via Digitalmars-d-learn
I can do it like this in C++: ``` template class def { friend typename abc; } ``` I am just hopelessly confused on how to achieve the same in D.