becoming more and more convinced that when sfinae opened the Turing hatch it doomed c++
A quick primer on type traits in modern C++
11–20 of 38 posts
Re: A quick primer on type traits in modern C++
#12The amount of background knowledge you need to understand what’s happening here... I don’t envy people who have to catch up becoming more and more convinced that when sfinae opened the Turing hatch it doomed c++
Re: A quick primer on type traits in modern C++
#13I found the use of 'if constexpr' in the example pretty nasty. I would have thought it more idiomatic to use std::enable_if to enable different implementations of 'algorithm' as in the example of 'construct' and 'destroy' given here: https://en.cppreference.com/w/cpp/types/enable_if
For new code it is to be preferred - it generates less symbols than enable_if, compiles faster (by a noticeable margin from my own experience) and makes for more readable code as you don't have to go look everywhere for the various enable_if cases.
Re: A quick primer on type traits in modern C++
#14The amount of background knowledge you need to understand what’s happening here... I don’t envy people who have to catch up becoming more and more convinced that when sfinae opened the Turing hatch it doomed c++
Re: A quick primer on type traits in modern C++
#15The amount of background knowledge you need to understand what’s happening here... I don’t envy people who have to catch up becoming more and more convinced that when sfinae opened the Turing hatch it doomed c++
I think that it's pretty easy if you just consider that what's happening between `template ` is a simple LISP whose values are types.
Re: A quick primer on type traits in modern C++
#16The amount of background knowledge you need to understand what’s happening here... I don’t envy people who have to catch up becoming more and more convinced that when sfinae opened the Turing hatch it doomed c++
Scott Meyers' next Effective C++ is going to be a doozy. Is it even possible to usefully categorize all the edge cases anymore?
Re: A quick primer on type traits in modern C++
#17The amount of background knowledge you need to understand what’s happening here... I don’t envy people who have to catch up becoming more and more convinced that when sfinae opened the Turing hatch it doomed c++
But what do I know, I haven't done C++ for about 5 years and was never that into it.
Re: A quick primer on type traits in modern C++
#18The amount of background knowledge you need to understand what’s happening here... I don’t envy people who have to catch up becoming more and more convinced that when sfinae opened the Turing hatch it doomed c++
Re: A quick primer on type traits in modern C++
#19The amount of background knowledge you need to understand what’s happening here... I don’t envy people who have to catch up becoming more and more convinced that when sfinae opened the Turing hatch it doomed c++
It just looks kinda wrong to me - If your generic template has to switch on what type it's been passed, surely you've made it too generic somewhere? Adding back conditional compilation or execution afterwards strikes me as the same sort of code-smell as checking if something is an instance of a given class before then casting it and calling a member - you've lost information and using some sort of reflection to get i…
Re: A quick primer on type traits in modern C++
#20The amount of background knowledge you need to understand what’s happening here... I don’t envy people who have to catch up becoming more and more convinced that when sfinae opened the Turing hatch it doomed c++
It just looks kinda wrong to me - If your generic template has to switch on what type it's been passed, surely you've made it too generic somewhere? Adding back conditional compilation or execution afterwards strikes me as the same sort of code-smell as checking if something is an instance of a given class before then casting it and calling a member - you've lost information and using some sort of reflection to get i…