On 2/5/2014 10:31 AM, Andrei Alexandrescu wrote:
On 2/5/14, 12:03 AM, Nick Sabalausky wrote:
If that's so, then I'd think lib authors could easily provide APIs that
offer GC by default and ARC as an opt-in choice with templating:

enum WantARC { Yes, No }
auto getFoo(WantARC arc = WantARC.No)() {
     static if(arc == WantARC.No)
         return getFoo().toGC();
     else {
     RCSlice!T x = ...;
         return x;
     }
}

Nice. Though I'd say just return RC strings and let the client call
toGC. They'd need to specify WantArc.No anyway so one way or another the
user has to do something.


Note the default parameter of WantARC.No. Therefore:

// GC:
T[] fooGC = getFoo();  // Nothing special specified

// ARC:
RCSlice!T = getFoo!(WantARC.Yes)();

Or am I missing something?

Reply via email to