Solrac@quokk.au to Programmer Humor@programming.devEnglish · 3 days agoIs my fear of C/++ Justified?quokk.auimagemessage-square38fedilinkarrow-up1175arrow-down15file-text
arrow-up1170arrow-down1imageIs my fear of C/++ Justified?quokk.auSolrac@quokk.au to Programmer Humor@programming.devEnglish · 3 days agomessage-square38fedilinkfile-text
minus-squaremkwt@lemmy.worldlinkfedilinkarrow-up13arrow-down1·2 days agoIf anyone is starting to learn C++, make sure to use books or training materials based on C++11 or later.
minus-squareglibg10b@lemmy.ziplinkfedilinkarrow-up8·2 days agoEven C++11 is pretty old. I would recommend at least C++17
minus-squareboonhet@sopuli.xyzlinkfedilinkarrow-up5·2 days agoAs someone who last touched any C++ books when C++11 was very new and has only written like 20-30 lines of non-tutorial C++ since then, what are some significant changes to the language that I should be aware of if I wanted to give it a try now?
minus-squareglibg10b@lemmy.ziplinkfedilinkarrow-up11arrow-down1·2 days agoA few examples: CTAD: Instead of std::pair<int, int> myPair{ 1, 2 }, you just write std::pair myPair{ 1, 2 } std::optional, std::variant and std::any Guaranteed copy elision in some cases, making it more feasible to apply the rule of 5 everywhere Attributes like [[nodiscard]] (compiler warning if an object or return value is discarded) and [[fallthrough]] (suppress a switch fallthrough warning) Generic lambdas ([](auto it){ /* do something */ }) std::string_view, which is much safer as a function parameter than const char*
minus-squareVictor@lemmy.worldlinkfedilinkarrow-up6·2 days ago Class Template Argument Deduction (CTAD) For anyone wondering, like I did.
If anyone is starting to learn C++, make sure to use books or training materials based on C++11 or later.
Even C++11 is pretty old. I would recommend at least C++17
As someone who last touched any C++ books when C++11 was very new and has only written like 20-30 lines of non-tutorial C++ since then, what are some significant changes to the language that I should be aware of if I wanted to give it a try now?
A few examples:
std::pair<int, int> myPair{ 1, 2 }, you just writestd::pair myPair{ 1, 2 }[](auto it){ /* do something */ })const char*For anyone wondering, like I did.
Modules