Template Classes

Component Testing for C++ supports assertions only for fully generic and fully specialized template classes. Partial specializations are not supported.

A contract referring to a generic template class is applied to every instance of this template class, unless a specific contract has been defined for an instance of this template class.

There may be a state machine description associated with the template class, and another with a template specialization. In such a case, the latter applies to the specific template instance, and the first applies to any other instance.

Same mechanism for invariant definition (There may be invariants associated with the template class, and other invariants with a template specialization. In such a case, the latter ones apply to the specific template instance, while the first one apply to any other instance.)

A wrap defined within a generic template class contract does not apply to specialization of the associated method. If you want to test a method specialization, you must define a WRAP into the contract associated to the class instance the method specialization belongs to.

It is not possible to define WRAPs for template methods within a non-template class.

Specialization

Specialized templates are templates for which some of the parameters are real. Full-specialization of a template is an instance of the template (all parameters are real).

Example

template <class T,int N> class C; // generic template, not a specialization

template <class T> class C<T,2>; // partial specialization (not supported by Component Testing for C++)

template <> class C<char *,2>; // full-specialization

Note When using full-specializations, latest ISO/IEC C++ standards suggest using the template prefix template<>.