Alright, C++ gurus, what am I doing wrong? https://gcc.godbolt.org/z/8MiELQ I'm trying to make a type trait to detect the presence of a specific member, but it…doesn't. (Note: replies snarking about C++ are not welcome or appreciated.)
Here is a reasonably re-usable type trait. I originally wrote it to check for methods (which is slightly more complicated, but the same idea). Turns out it works for members too as long as they're public. https://godbolt.org/z/bMtZAq Can't claim it was my invention tho.
-
-
clarification on the "my invention" thing. It's pieced together from reading about other peoples' attempts. Stackoverflow, blogs, etc. I tried to boil it down to as essential and few lines as possible.
-
Here's an edited one. Takes some points from other answers. Also added an example that illustrates you can also check the type of the member, which other answers are not terse about. https://godbolt.org/z/IoT3GI
Keskustelun loppu
Uusi keskustelu -
Lataaminen näyttää kestävän hetken.
Twitter saattaa olla ruuhkautunut tai ongelma on muuten hetkellinen. Yritä uudelleen tai käy Twitterin tilasivulla saadaksesi lisätietoja.