CppCon 2017: Arthur O'Dwyer “A Soupçon of SFINAE”

preview_player
Показать описание

Following on Arthur's "Template Normal Programming" from CppCon 2016, this will be a concise cookbook of SFINAE recipes — ways of getting the compiler to do one thing in one circumstance and another thing in another circumstance. The recipes presented will include:
- Partial specialization of struct templates
- std::bool_constant
- std::conditional_t
- Expression SFINAE on return types (using decltype)
- Expression SFINAE in a defaulted template type parameter
- std::enable_if_t as a defaulted template type parameter
- Tag dispatch on std::true_type and std::false_type
- "Meta-tag-dispatch" on true and false as template non-type parameters
- priority_tag<N> for tag dispatch with "fallback" cases
- bool_if_t as a template non-type parameter
In each case, we'll show a real code example where the recipe is the clearest and best way to get the job done. This will draw on Arthur's recent "STL From Scratch".

Arthur O'Dwyer: Nominum, Core Engineering

Arthur O'Dwyer worked for many years at Green Hills Software, making the world's most optimizing C and C++ compilers. Now he works at Nominum in San Francisco. Arthur is the showrunner of the Bay Area C++ meetup, which meets practically every week these days.


*-----*
*-----*
Рекомендации по теме
Комментарии
Автор

Behold Arthur O' Dwyer.... the absolute template Wizard!!!

Teach me your mysterious ways!

allopeth
Автор

Really good talk, lots of golden nuggets in there.

amaiorano
Автор

The priority_tag trick is brillant and elegant.

DonCorleone
Автор

On slide 61 .. there are two names distance_impl and impl ... is that intentional?

videofountain
Автор

slide 25 !! expr, Args ??? I couldn't figure out what is going on??

soulimanemammar
Автор

hmmm.... not everyone is as gifted as Scott Meyers or Herb Sutter at explaining things... This may be easy to understand for someone who knows a whole lot about the topic already... but wasn't for me.

Ok, I get that the compiler will always select a more specific version, over a more generic one. I found that the presenter spent a lot of time repeating that. But what would have been more helpful, IMHO, is for him to mentally walk through the evaluation process a compiler walks through, to actually determine that. I felt like he was just showing off how good he was, with all the tricks he came up with. But spend too little time to show how it worked. For instance, he introduces what declval() is... and soon jumps into something like @20:28, without explaining much about it. If someone didn't know what declval was (such was my case), I doubt they could go from learning that, to perfectly understanding the bit I pointed out before, with the information he provided.

But hey... it's free and he owes me nothing.

enriquebenedicto
Автор

Is it just me or Arthur is extremely hard to follow. I think he thinks he is clear.

rude_broccoli
Автор

This is the reason why c++ sucks !
Programming languages need to be about being able to use them (easily). Not having to do a 3 hr lecture and 3 weeks training on a single topics..

utki