我在需要时利用这一合成物参数:
举例说:
t_array(const t_ownership_policy::t_take& policy, THESpecialType* const arg);
在电话中使用:
t_array array(t_ownership_policy::Take, THESpecialTypeCreate(...));
<代码>t_ Ownership_policy:t_take is only a dummy overload disambiguator打字。
In this system, there are multiple policies, each with separate types. I favored unique types per policy because a typed enumeration (for example) does not support initialization as easily, and it s too easy to pass an unsupported policy to a function or constructor. Polymorphic policies can reduce symbol count, but it s a pain because it pushes error detection to runtime.
For returning :
void func(t_container<t_type>& outValue);
<代码>t_container 是你选择的每箱集装箱类型。 然后,集装箱类型已经安装了必要的碎块。 该集装箱可以是共有的-ptr
,也可以是你写的某种专业。
and for more elaborate types, i ll often use syntax like so:
void func(t_special_container& outValue) {
...
outValue.take(ptr);
- or -
outValue.copy(ptr);