Difference between revisions of "CXAutoReferenceNew"

From cxwiki

(Created page with "<div class="mw-parser-output">The CXAutoReferenceNew templated class allows reference-counted objects to be instantiated and simultaneously placed into a CXAutoReferenceNoNull...")
 
 
Line 1: Line 1:
<div class="mw-parser-output">The CXAutoReferenceNew templated class allows reference-counted objects to be instantiated and simultaneously placed into a CXAutoReferenceNoNull-derived storage. This provides a number of benefits over manual allocation, including:</div>  
+
<div class="mw-parser-output"><div class="mw-parser-output">The CXAutoReferenceNew templated class allows reference-counted objects to be instantiated and simultaneously placed into a [[CXAutoReferenceNoNull]]-derived storage. This provides a number of benefits over manual allocation, including:</div>  
 
*The data type is&nbsp;guaranteed not null, simplifying development and slightly improving compiled code performance.  
 
*The data type is&nbsp;guaranteed not null, simplifying development and slightly improving compiled code performance.  
 
*A reference-counted object can be constructed as a member of a parent object&nbsp;without extra construction syntax.  
 
*A reference-counted object can be constructed as a member of a parent object&nbsp;without extra construction syntax.  
 
*Construction syntax is simplified; eg.  
 
*Construction syntax is simplified; eg.  
**Without: CXAutoReference<SomeObject> someObject = CXAutoReference<SomeObject>::Swallow(new SomObject(param0, param1));  
+
**Without: ''CXAutoReference<SomeObject> someObject = CXAutoReference<SomeObject>::Swallow(new SomObject(param0, param1));''
**With: CXAutoReferenceNew<SomeObject> someObject(param0, param1);   
+
**With: ''CXAutoReferenceNew<SomeObject> someObject(param0, param1);''    
  
&nbsp;
+
''CXAutoReferenceNew<T>'' is designed to act in a manner syntactically equivalent&nbsp;to a ''T* __nonnull'' where possible.
 +
</div>

Latest revision as of 07:04, 23 February 2018

The CXAutoReferenceNew templated class allows reference-counted objects to be instantiated and simultaneously placed into a CXAutoReferenceNoNull-derived storage. This provides a number of benefits over manual allocation, including:
  • The data type is guaranteed not null, simplifying development and slightly improving compiled code performance.
  • A reference-counted object can be constructed as a member of a parent object without extra construction syntax.
  • Construction syntax is simplified; eg.
    • Without: CXAutoReference<SomeObject> someObject = CXAutoReference<SomeObject>::Swallow(new SomObject(param0, param1));
    • With: CXAutoReferenceNew<SomeObject> someObject(param0, param1);

CXAutoReferenceNew<T> is designed to act in a manner syntactically equivalent to a T* __nonnull where possible.