Template capabilities


Detailed Description

Some compilers still do not fully implement the template syntax. These macros can be used to select between alternate implementations of blocks of code, namely, one that takes advantage of template programming techniques and a less efficient one which is compatible with all compilers.


Defines

#define QL_DECLARE_TEMPLATE_SPECIALIZATIONS
 Blame Microsoft for this one...

#define QL_ALLOW_TEMPLATE_METHOD_CALLS   1
 Blame Microsoft for this one...

#define QL_TYPENAME   typename
 Blame Microsoft for this one...

#define QL_TEMPLATE_METAPROGRAMMING_WORKS   1


Define Documentation

#define QL_DECLARE_TEMPLATE_SPECIALIZATIONS
 

Blame Microsoft for this one...

They decided that a declaration and a definition of a specialized template function amount to a redefinition and should issue a linker error. For the code to be portable, template specializations should be declared (as opposed to defined) only if this macro is defined.

#define QL_ALLOW_TEMPLATE_METHOD_CALLS   1
 

Blame Microsoft for this one...

Their compiler cannot cope with method calls such as

Handle<Type1> h1(whatever); h2 = h1.downcast<Type2>();

For compatibility, a workaround should be implemented (which of course will be less solid or more comples - as I said, blame Microsoft...)

#define QL_TYPENAME   typename
 

Blame Microsoft for this one...

They decided that typename can only be used in template declarations and not in template definitions.

#define QL_TEMPLATE_METAPROGRAMMING_WORKS   1
 

Template metaprogramming techniques (see T. L. Veldhuizen, Using C++ Template Metaprograms, C++ Report, Vol 7 No. 4, May 1995, available at http://extreme.indiana.edu/~tveldhui/papers) are sometimes too advanced for the template implementation of current compilers.


QuantLib.org
QuantLib
Hosted by
SourceForge.net Logo
Documentation generated by
doxygen