@odinthenerd @odin odinthe thener nerd – not the god Auto-Intern GmbH 1
@odinthenerd Hana Dusíková compile time regex Auto-Intern GmbH 2
@odinthenerd Mixins Auto-Intern GmbH 3
@odinthenerd Auto-Intern GmbH 4
@odinthenerd Bare metal drivers • • • • • • Auto-Intern GmbH 5
@odinthenerd Bare metal drivers • In assembler • • • • • Auto-Intern GmbH 6
@odinthenerd Bare metal drivers • In assembler • • • • • Auto-Intern GmbH 7
@odinthenerd Bare metal drivers • In assembler • In C with Macros • • • • Auto-Intern GmbH 8
@odinthenerd Bare metal drivers • In assembler • In C with Macros • • • • Auto-Intern GmbH 9
@odinthenerd Bare metal drivers • In assembler • In C with Macros • By hand in C++ • • • Auto-Intern GmbH 10
@odinthenerd Bare metal drivers • In assembler • In C with Macros • By hand in C++ • • • Auto-Intern GmbH 11
@odinthenerd Bare metal drivers • In assembler • In C with Macros • By hand in C++ • Aggregation • • Auto-Intern GmbH 12
@odinthenerd Bare metal drivers • In assembler • In C with Macros • By hand in C++ • Aggregation • • Auto-Intern GmbH 13
@odinthenerd Bare metal drivers • In assembler • In C with Macros • By hand in C++ • Aggregation • Inheritance + virtual functions • Auto-Intern GmbH 14
@odinthenerd Bare metal drivers • In assembler • In C with Macros • By hand in C++ • Aggregation • Inheritance + virtual functions • Auto-Intern GmbH 15
@odinthenerd Bare metal drivers • In assembler • In C with Macros • By hand in C++ • Aggregation • Inheritance + virtual functions • Inheritance + CRTP Auto-Intern GmbH 16
@odinthenerd Inspiration in old book form Auto-Intern GmbH 17
@odinthenerd Bare metal drivers • In assembler • In C with Macros • By hand in C++ • Aggregation • Inheritance + virtual functions • Inheritance + CRTP Auto-Intern GmbH 18
@odinthenerd Even your cat will like you! Auto-Intern GmbH 19
@odinthenerd Implementation details Auto-Intern GmbH 20
@odinthenerd Mixin composition ring() guts blow() more_guts Auto-Intern GmbH 21
@odinthenerd Code example auto thing = mixin::compose( mixin::interface<bells, whistles>, guts, more_guts); Auto-Intern GmbH 22
@odinthenerd Code example auto thing = mixin::compose( mixin::interface<bells, whistles>, guts, more_guts); Auto-Intern GmbH 23
@odinthenerd Code example auto thing = mixin::compose( mixin::interface<bells, whistles>, guts, more_guts); Auto-Intern GmbH 24
@odinthenerd Code example auto thing = mixin::compose( mixin::interface<bells, whistles>, guts{haggis}, more_guts); Auto-Intern GmbH 25
@odinthenerd Code example auto thing = mixin::compose( mixin::interface<bells, whistles>, guts{haggis}, more_guts); thing.ring(); Auto-Intern GmbH 26
@odinthenerd Code example auto thing = mixin::compose( mixin::interface<bells, whistles>, guts{haggis}, more_guts, my_allocator{arena}); Auto-Intern GmbH 27
@odinthenerd Definition of terms • Composition Auto-Intern GmbH 28
@odinthenerd Mixin composition ring() guts blow() more_guts my_allocator Auto-Intern GmbH 29
@odinthenerd Composition auto thing = mixin::compose( mixin::interface<bells, whistles>, guts{haggis}, more_guts, my_allocator{arena}); Auto-Intern GmbH 30
@odinthenerd Definition of terms • Composition • Interface / Implementation Auto-Intern GmbH 31
@odinthenerd Mixin composition ring() guts blow() more_guts my_allocator Auto-Intern GmbH 32
@odinthenerd Interface template < typename T> struct bells : T { void ring(); }; Auto-Intern GmbH 33
@odinthenerd Interface – concept template < typename T> struct bells : T { void ring(); }; Auto-Intern GmbH 34
@odinthenerd Interface – adds to the composition objects interface template < typename T> struct bells : T { void ring(); }; Auto-Intern GmbH 35
@odinthenerd Mixin composition ring() guts blow() more_guts my_allocator Auto-Intern GmbH 36
@odinthenerd Implementation struct guts { }; Auto-Intern GmbH 37
@odinthenerd Definition of terms • Composition • Interface / Implementation • Abilities Auto-Intern GmbH 38
@odinthenerd Mixin composition ring() guts blow() more_guts my_allocator Auto-Intern GmbH 39
@odinthenerd Abilities struct ringable{}; Auto-Intern GmbH 40
@odinthenerd Find mixins by ability template < typename T> struct bells : T{ void ring(){ for_each(this, ability<ringable>, []( auto & a){ a. ring (); }); } }; Auto-Intern GmbH 41
@odinthenerd Associating abilities with a mixin using guts = make_mixin< guts_impl, ringable, magic_frog_power, allocator_use_capable>; Auto-Intern GmbH 42
@odinthenerd Definition of terms • Composition • Interface / Implementation • Abilities • Requirements Auto-Intern GmbH 43
@odinthenerd Find mixins by ability 0-n template < typename T> struct bells : T{ void ring(){ for_each(this, ability<ringable>, []( auto & a){ a. ring (); }); } }; Auto-Intern GmbH 44
@odinthenerd Find mixins by ability exactly 1 template < typename T> struct bells : T{ void ring(){ execute(this, ability<ringable>, []( auto & a){ a. ring (); }); } }; Auto-Intern GmbH 45
@odinthenerd Find mixins that match an arbitrary predicate template < typename T> struct bells : T{ void ring(){ call_on(this, predicate<my_selector>, []( auto & a){ a. ring (); }); } }; Auto-Intern GmbH 46
@odinthenerd Mixin composition ring() guts blow() more_guts my_allocator Auto-Intern GmbH 47
@odinthenerd Return type of compose() template < typename ... Ts> class composition: public call_<detail::make_base<composition<Ts...>>, Ts...> { std::tuple<Ts...> data; //… }; Auto-Intern GmbH 48
@odinthenerd Return type of compose() template < typename ... Ts> class composition: public call_<detail::make_base<composition<Ts...>>, Ts...> { std::tuple<Ts...> data; //… }; protect<access<composition<Ts …>>> Protect Access Auto-Intern GmbH 49
@odinthenerd Protect template < typename T> struct protect : protected T {}; protect<access<composition<Ts …>>> Protect Access Auto-Intern GmbH 50
@odinthenerd Return type of compose() template < typename ... Ts> class composition: public call_<detail::make_base<composition<Ts...>>, Ts...> { std::tuple<Ts...> data; //… }; interface1<protect<access<composition<Ts …>>>> Interface 1 Protect Access Auto-Intern GmbH 51
@odinthenerd Return type of compose() template < typename ... Ts> class composition: public call_<detail::make_base<composition<Ts...>>, Ts...> { std::tuple<Ts...> data; //… }; interface2<interface1<protect<access<composition<Ts …>>>>> Interface 2 Interface 1 Protect Access Auto-Intern GmbH 52
@odinthenerd Return type of compose() template < typename ... Ts> class composition: public call_<detail::make_base<composition<Ts...>>, Ts...> { std::tuple<Ts...> data; //… }; interface3<interface2<interface1<protect<access<composition<Ts …>>>>>> Interface 3 Interface 2 Interface 1 Protect Access Auto-Intern GmbH 53
@odinthenerd Return type of compose() template < typename ... Ts> class composition: public call_<detail::make_base<composition<Ts...>>, Ts...> { std::tuple<Ts...> data; //… }; interface3<interface2<interface1<protect<access<composition<Ts …>>>>>> Composition Interface 3 Interface 2 Interface 1 Protect Access Auto-Intern GmbH 54
@odinthenerd Completing the circle template < typename ... Ts> class composition: public call_<detail::make_base<composition<Ts...>>, Ts...> { std::tuple<Ts...> data; //… }; interface3<interface2<interface1<protect<access<composition<Ts …>>>>>> Composition Interface 3 Interface 2 Interface 1 Protect Access Auto-Intern GmbH 55
@odinthenerd Access template < typename T> struct access { auto & get_data(){ return static_cast <T*>( this )-> data ; } }; Composition Interface 3 Interface 2 Interface 1 Protect Access Auto-Intern GmbH 56
@odinthenerd Encapsulation template < typename ... Ts> class composition: public call_<detail::make_base<composition<Ts...>>, Ts...> { std::tuple<Ts...> data; friend access<composition<Ts...>>; //… }; Composition Interface 3 Interface 2 Interface 1 Protect Access Auto-Intern GmbH 57
Recommend
More recommend