Template Metaprogramming: Type Traits
Template Metaprogramming: Type Traits Part 1 CppCon 2020 1 Jody Hagins jhagins@maystreet.com coachhagins@gmail.comTemplate Metaprogramming: Type Traits CppCon 2020 2 IntroductionIntended Audience depth, slow current • Not necessarily beginner to C++, but beginner to traditional template metaprogramming techniques 3Intended Audience • Beginner/Intermediate • Gentle entry: swimming pool to river depth, slow current • Not necessarily beginner to C++, but beginner to traditional template metaprogramming techniques • Type traits part of standard library for ~10 years 3Intended Audience • Beginner/Intermediate0 码力 | 403 页 | 5.30 MB | 5 月前3Template-Less Meta-Programming
1 / 58Template Metaprogramming (TMP) Template Metaprogramming (TMP) templateusing meta_fun = this_talk ; 2 / 58❓static_assert(Template::Metaprogramming::is_hard); // ✔ 3 / 58❓s 58❓static_assert(Template::Metaprogramming::is_hard); // ✔ ❓static_assert(Template::Metaprogramming::is_powerful); // ✔ 3 / 58❓static_assert(Template::Metaprogramming::is_hard); // ✔ ❓static_assert( ❓static_assert(Template::Metaprogramming::is_powerful); // ✔ ❓static_assert(( Template::Metaprogramming::is_easy and Template::Metaprogramming::is_powerful and Template::Metaprogramming::has_nice_error_messages 0 码力 | 130 页 | 5.79 MB | 5 月前3Just-In-Time Compilation: The Next Big Thing
std::string; // [Future] Abstract Syntax Tree (AST) node P1717: COMPILE TIME METAPROGRAMMING IN C++ P1717: COMPILE TIME METAPROGRAMMING IN C++ 5 . 10READ–EVAL–PRINT LOOP (REPL) READ–EVAL–PRINT LOOP (REPL) std::string; // [Future] Abstract Syntax Tree (AST) node P1717: COMPILE TIME METAPROGRAMMING IN C++ P1717: COMPILE TIME METAPROGRAMMING IN C++ std::vector v{}; 5 . 10READ–EVAL–PRINT LOOP (REPL) READ–EVAL–PRINT std::string; // [Future] Abstract Syntax Tree (AST) node P1717: COMPILE TIME METAPROGRAMMING IN C++ P1717: COMPILE TIME METAPROGRAMMING IN C++ std::vector v{}; v.push_back("int"); v.push_back("double");0 码力 | 222 页 | 5.45 MB | 5 月前3The Hitchhiker’s Guide to Logical Verification
. . . . . . . . . . . . . . 106 7 Metaprogramming 109 7.1 Tactics and Tactic Combinators . . . . . . . . . . . . . . . . . . . . . . . 110 7.2 The Metaprogramming Monad . . . . . . . . . . . . . . . axioms and quotient types, making it convenient to verify mathematics. It includes a convenient metaprogramming framework, which can be used to program custom proof automation. It includes a modern user interface symbols Chapter 7 Metaprogramming Like most proof assistants, Lean can be extended with custom tactics and other functionality. Programming Lean itself is called metaprogramming. Lean’s meta- programming0 码力 | 215 页 | 1.95 MB | 1 年前3Google C++ Style Guide
will make it more obvious to readers, as with auto. Template metaprogramming Avoid complicated template programming. Template metaprogramming refers to a family of techniques that exploit the fact that and can be used to perform arbitrary compile-time computation in the type domain. Template metaprogramming allows extremely flexible interfaces that are type safe and high performance. Facilities like template metaprogramming are often obscure to anyone but language experts. Code that uses templates in complicated ways is often unreadable, and is hard to debug or maintain. Template metaprogramming often0 码力 | 83 页 | 238.71 KB | 1 年前3EXPLORATION OF C++20 METAPROCRAMMING
EXPLORATION OF C++20 METAPROGRAMMING INBAL LEVIWHO AM I? • AC++ enthusiast. • An embedded software engineer at Solar Edge working on smart home. • One of the organizers of CoreCpp conference and user extensive use of templates 4 • We’ll see how C++20 creates a paradigm shift in the way we use metaprogramming. And I don’t blame them…• Part 0: (Prologue) What are templates? • Part I: Adding templates C++20PART IV: CONDITIONS AT COMPILE TIME USING C++20 25• C++20 created a paradigm shift in metaprogramming. • Concepts and constraints allow the user to introduce a new ‘type category’ (vs. type) to0 码力 | 50 页 | 2.59 MB | 5 月前3An Introduction to Lean
. . . . . . . . . . . . . . . . . . . . . . . . . . . 45 5 Using Automation in Lean 46 6 Metaprogramming in Lean 47 3 CONTENTS 4 Bibliography 48 1 Overview This introduction offers a tour of Lean results are indeed correct. Which brings us to yet another aspect of Lean, namely, its role as a metaprogramming language. Many of Lean’s internal data structures and procedures are exposed and available within language of Lean itself, via a monadic interface. We refer to the use of these procedures as “metaprogramming” because they take us outside the formal framework: the access points to the API are declared0 码力 | 48 页 | 191.92 KB | 1 年前3Reflection Based Libraries to Look Forward To
information about other “code” Operate on that information Reflection? 7How is this different from metaprogramming? 8Not much :) Operate on values instead of types Syntactic difference, not semantic Compiler already there A neat and consistent “bag” of features to expand in the future Reflection vs metaprogramming 9Other languages Venturing into some alien worlds. 10Python 11At runtime your code can Access 96How do we find function signature? P3096 helps :) "Function Parameter Reflection" Can also do metaprogramming (Boost.CallableTraits etc) Runtime virtual interface means cannot use template types Member0 码力 | 118 页 | 14.33 MB | 5 月前3Can Data-Oriented-Design be Improved?
1960s • FORTRAN • Lisp • 1980s • OOP • Structured programming • Modules • 2000s • Template metaprogramming • Concurrency • 2020s • ??? 3What is DoD about? • DoD (“Data oriented design”) • Not about STL algorithms • Ranges • Functions pointers • In compile-time code • Types are data (ex: metaprogramming) • We can apply ideas from functional programming in C++ 17Introducing “transformation-oriented 28Example 1 (part 1) #include#include namespace Local { // May be found in metaprogramming template constexpr bool TypeInListImpl() { 0 码力 | 39 页 | 1.18 MB | 5 月前3Programming in Lean Release 3.4.2
function definitions. One novel feature of Lean is that its programming language is also a metaprogramming language, which is to say, it can be used to extend the functionality of Lean itself. To that revert hypotheses, peform an action, and then reintroduce new hypotheses with the same names. Metaprogramming in Lean requires us to be mindful of and explicit about the distinction between expressions in To understand what is going on in situations like this, it is important to know that Lean’s metaprogramming framework provides three distinct Lean types that are relevant to constructing syntactic expressions:0 码力 | 51 页 | 220.07 KB | 1 年前3
共 224 条
- 1
- 2
- 3
- 4
- 5
- 6
- 23