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 oriented: shallow depth, slow current • Not necessarily beginner to C++, but beginner to traditional template metaprogramming techniques 3Intended Audience • Beginner/Intermediate • Gentle entry: swimming oriented: shallow 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 Audience0 码力 | 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 月前3Secrets of C++ Scripting Bindings
about SWIG Learned that Python is wrong for embedding (Global state), chose Lua 2008 - Created SWIG Starter Kit SWIG is great for binding to other languages, but requires a second build step (Side note: this and through its development and via bug reports and contributions from users, I learned about: Template Meta Programming 7 . 4Copyright Jason Turner @le�icus emptycrate.com/idocpp ChaiScript ChaiScript and through its development and via bug reports and contributions from users, I learned about: Template Meta Programming Lambdas 7 . 4Copyright Jason Turner @le�icus emptycrate.com/idocpp ChaiScript0 码力 | 177 页 | 1.65 MB | 5 月前3Back to Basics: Generic Programming
Programming CppCon 2024 Define a Template template <template-parameters> declaration; declaration can be • class / struct • function • type alias • variable • concept template-parameter is class | typename typename identifier [= default-value] Template definition should be in a header file12 David Olsen – Generic Programming CppCon 2024 Class Template Definition templateclass pair { T https://godbolt.org/z/rejh9YPhK13 David Olsen – Generic Programming CppCon 2024 Class Template Definition template class pair { T m0; U m1; public: pair() { } pair(T v0, U v1) : m0(v0) 0 码力 | 175 页 | 1.16 MB | 5 月前3Back to Basics: Templates - Part 1
Basics: Templates – Part 1 Copyright © 2021 Bob Steagall Overview • Rationale • Template fundamentals • Template categories in detail 2CppCon 2021 – Back to Basics: Templates – Part 1 Copyright © Bob Steagall Template Categories 15CppCon 2021 – Back to Basics: Templates – Part 1 Copyright © 2021 Bob Steagall Function Templates (C++98/03) • Recipes for making functions 16 templateT T const& min(T const& a, T const& b); { return (a < b) ? a : b; } template void swap(T& a, T& b); template void sort(RandomIt first, RandomIt last, Compare 0 码力 | 68 页 | 436.75 KB | 5 月前3Back to Basics: Templates Part 2
Templates • C++ supports generic programming with templates • A template is a parametrized description of a family of some facility • A template is not a thing – it is a recipe for making things • C++ provides kinds of templates • Function templates • Class templates • Member function templates • Alias template • Variable templates • Lambda templates 2CppCon 2021 – Back to Basics: Templates – Part 2 Copyright name is an identifier that denotes an entity • Every template has a name • Every template specialization has a name, formally known as a template-id • A declaration introduces one or more names into0 码力 | 80 页 | 490.15 KB | 5 月前3Extending and Simplifying C++: Thoughts on Pattern Matching using 'is' and 'as', and Can C++ be 10x Simpler & Safer?
“all about C++” variable operator “thing” 7it is value 8it is type 9it is predicate 10it is template 11it is concept 12it is empty 132 Usually, a couple of years old. There is always a paperP2392 (predicate) ? x is empty x is empty ? x is Template x is Template ? x is Concept x is Concept ? X is Type X is Y ? X is Concept X is Concept ? X is Template X is Template ? Testing Variable Testing Type 15x 15x is Type Actual type Expected template< typename C, typename X > constexpr auto is( X const& ) -> bool; is(x); 16x is Type 17x is Type 18x is Type 19x is Type 20x is Type 21x is Type 0 码力 | 108 页 | 5.08 MB | 5 月前3Implementing Particle Filters with Ranges
1CONCEPTS templateconcept ParticleLike = std::is_object_v && requires(T a) { { a.state }; { a.weight } -> std::convertible_to ; }; template && requires(F f, T t) { { t.state = f(t.state) }; }; template concept ReweightFn = ParticleLike && requires(F f, T t) { { 10CONCEPTS template concept ParticleLike = std::is_object_v && requires(T a) { { a.state }; { a.weight } -> std::convertible_to ; }; template 0 码力 | 83 页 | 4.70 MB | 5 月前3Symbolic Calculus for High-Performance Computing: From Scratch Using C++23
Architecture Substitution Construction Conclusion Mixing with lambdas and template parameter Lambdas as default template parameter 1 template2 struct symbol {}; The result 1 symbol decltype(y)> << std :: endl; // 0 Also works with NTTP 1 template 2 struct symbol {}; Conclusion Mixing lambdas and default template parameter allow to create uniquely-typed symbols. CppCon Using plain C++ to generate uniquely-typed symbols The ONE trick to remember: the “lambda” trick 1 template 2 struct symbol {}; 3 4 symbol a; 5 symbol w; 6 symbol t; 7 symbol phi; 8 9 0 码力 | 70 页 | 1.80 MB | 5 月前3Embracing CTAD
NinaWhat is in this talk • What is Class Template Argument Deduction (CTAD) and how it makes our life easierWhat is in this talk • What is Class Template Argument Deduction (CTAD) and how it makes makes our life easier • The principles of how CTAD worksWhat is in this talk • What is Class Template Argument Deduction (CTAD) and how it makes our life easier • The principles of how CTAD works • CTAD take down or CTAD sales pitch • PopcornWhat is CTAD ?Deducing function-template template argument templatevoid myFunc(const T&){} myFunc (1); // invokes 0 码力 | 98 页 | 4.62 MB | 5 月前3
共 290 条
- 1
- 2
- 3
- 4
- 5
- 6
- 29
相关搜索词
TemplateMetaprogrammingTypeTraitsLessMetaProgrammingSecretsofC++ScriptingBindingsBacktoBasicsGenericTemplatesPartExtendingandSimplifyingThoughtsonPatternMatchingusingisasCanbe10xSimplerSaferImplementingParticleFilterswithRangesSymbolicCalculusforHighPerformanceComputingFromScratchUsing23EmbracingCTAD