...
- Stubs for C++ templates are supported for the following compilers:
- GNU GCC 5.x or newer
- Clang C/C++ Compiler 5 or newer
- Microsoft Visual C++ 14.1 (2017) or newer
- GNU GCC 5.x or newer
- Stubs for C++ templates are not supported for:
Constructors and destructors
Conversion operators
Implicitly defined functions
Defaulted and deleted functions
Friend functions
- To use stubs for C++ templates, all template argument types must be defined before the original template definition (in all translation units where the instance is created).
- Stubbing C++ template explicit/full specializations is possible regardless of whether C++ template stubs functionality is enabled.
Stubbing explicit/full specializations that are class methods is not supported.
Example of code where stubs for templates cannot be used:Code Block // = from func.h // "S" type (used in instance below) is unknown template <typename T> void func(T t) {} // = from struct.h struct S {}; // stub for func<S>(S) cannot be used void m(S s) { func(s); // call to be stubbed }
To enable stubs for templates, the code can be changed to:Code Block // = from struct.h // Type S defined before template function definition struct S {}; // = from func.h // "S" type (used in instance below) is defined template <typename T> void func(T t) {} // stub for func<S>(S) can be used void m(S s) { func(s); // call to be stubbed }
Depending on the situation you might need to change the order, structure or content of the include files.- Stubbing C++ template explicit/full specializations is possible regardless of whether C++ template stubs functionality is enabled.
Stubbing explicit/full specializations that are class methods is not supported.
| Scroll Pagebreak |
|---|