作者: Andrew Lumsdaine , Ronald Garcia
DOI:
关键词:
摘要: Most programming languages do not allow programs to inspect their static type information or perform computations on it. C++, however, lets programmers write template metaprograms, which enable encode information, compile-time computations, and make decisions about run-time behavior. Many C++ libraries applications use metaprogramming build specialized abstraction mechanisms, implement domain-specific safety checks, improve performance. Template is an emergent capability of the system, language specification informal imprecise. As a result, often involves heroic feats leads code that difficult read maintain. Furthermore, many template-based generation optimization techniques rely particular compiler implementations, rather than semantics, for performance gains. Motivated by capabilities metaprogramming, this thesis documents some common patterns, including computation, analysis, generative programming, encoding checks. It also notable shortcomings current practice, limited support reflection, semantic ambiguity, other issues arise from pioneering nature metaprogramming. Finally, presents design foundational language, motivated analysis allows statically generate code. The specified as core calculus its are presented in idealized setting.