On Thursday, 23 February 2017 at 14:24:14 UTC, Adam D. Ruppe wrote:
On Thursday, 23 February 2017 at 10:48:38 UTC, kinke wrote:
That's not elegant. You need a factory function for each type containing one of these structs then.

A constructor is just a factory function with a special name... it is almost equal amount of work.

Sorry but this is just completely wrong. RAII is all about me NOT having to call special functions all over the place.

struct S
{
    this() { /* initialize */ }
}

S[123] myArray; // hooray, no need to invoke a factory in a loop

struct Container
{
    S s;
    // hooray, implicit this() automatically calls s.this()
}
  • RAII Arun Chandrasekaran via Digitalmars-d-learn
    • Re: RAII ketmar via Digitalmars-d-learn
      • Re: RAII kinke via Digitalmars-d-learn
        • Re: RAII Adam D. Ruppe via Digitalmars-d-learn
          • Re: RAII kinke via Digitalmars-d-learn
            • Re: RAII kinke via Digitalmars-d-learn
      • Re: RAII Arun Chandrasekaran via Digitalmars-d-learn
        • Re: RAII ketmar via Digitalmars-d-learn
    • Re: RAII Adrian Matoga via Digitalmars-d-learn
    • Re: RAII cym13 via Digitalmars-d-learn
      • Re: RAII Arun Chandrasekaran via Digitalmars-d-learn

Reply via email to