Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why do all concrete templates have a parameter called Rep? What are the benefits of factoring out Representation?

0
Posted

Why do all concrete templates have a parameter called Rep? What are the benefits of factoring out Representation?

0

A25: All Resolve/C++ concrete templates (with the rare exception of the ones implemented in native C++) have a template parameter called Rep. The actual parameter is required to be an instance of Representation component and is used as the representation of the concrete template. Compared to the traditional C++ approach of using private data fields for representation, this schema has several important benefits. First, the memory management strategy for the representation fields is factored out and encapsulated in the Representation component. This significantly improves performance without jeopardizing correctness or simplicity. Second, the swap operator and Clear operation are inherited and re-exported by the concrete template. Finally, this schema makes the representation fields access syntax uniform with the access syntax of record fields.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123