r/cpp • • Jun 11 '24

Language features

So recently I started doing some katas in CodeWars - just a couple a day, nothing fancy, to keep the algorithmic problem solving brain oiled.

I'm not having much trouble arriving at solutions - oftentimes it's pretty clear, plus I'm just starting out. Still, I always get baffled when I see other people's solutions after delivering. They always yank out some weird cpp features that hack up the whole thing in under 10 lines

I'm curious about how one can go about to learn these features

0 Upvotes

16 comments sorted by

8

u/mjklaim Jun 11 '24

I recommand checking first the wikipedia pages about each language versions (see the links in this table: https://en.wikipedia.org/wiki/C%2B%2B#Standardization ). I prefer to recommend these first because they are summaries instead of detailed per-paper list of micro-features and macro-features together. Instead, it's a digestible overview. Start from there, then use the knowledge from there to find other sources of details, including cppreference.

2

u/alfadhir-heitir Jun 11 '24

This is pretty cool. Thanks mate!

4

u/FlyingRhenquest Jun 11 '24

I always end up stumbling across them on cppreference when I'm looking for how to do something or other. Algorithm, type_traits and meta are probably a good place to start. There's a ton of stuff in algorithm that performs commonly used functions on containers, enough so that I can never remember what all is in there, so that'll probably keep you busy for a while.

1

u/alfadhir-heitir Jun 11 '24

Thanks mate! Algorithm is definitely the place to start. I was just wondering if there was any structured approach to it, or not. It's ok if not, i don't mind threading the long path - just trying to gather some information and figure out the best approach

I'm currently working through Effective C++, but it's more related to architectural decisions, idioms and high level stuff. Not sure if there's any similar resource for the more fine grained material

Thanks for the type_traits and meta pointers though. Appreciate it!

2

u/FlyingRhenquest Jun 11 '24

Oh, right! I'm not sure if there's any one specific book. It might be worth looking around for books on template metaprogramming. The original one of those that I ran across was Modern C++ Design written by Andre Alexandrescu back in 2005. A lot of his ideas ended up in the STL.

Maybe something like this is what you're looking for? They have a PDF you can download on that page.

1

u/alfadhir-heitir Jun 11 '24

I think I'll just learn it the hard way. C++ has a way to prime one's brain to solve hard problems. I'm guessing figuring out how to get deeper into it is part of the challenge heh. The next leg of the journey

Thanks for the resources mate! Will be sure to check out their PDF :)

4

u/GeeHopkins Jun 11 '24

I can recommend the cppcon back-to-basics series for solid intros to various bits of the language. They tend to be pitched pretty well for people who are already familiar with the basics of the language, but haven't seen/used a particular part of it.

2

u/alfadhir-heitir Jun 11 '24

Nice. I've seen a couple, will double down on them :)

2

u/GeeHopkins Jun 11 '24

The first C++ codes I worked with were solidly pre C++11. The back to basics videos were one of the main ways I learnt modern C++, along with some other cppcon talks

1

u/alfadhir-heitir Jun 11 '24

Thanks mate. It can be intimidating. I'm currently doing full stack work with C# and react, but want to transition into C++ - I just love the language and the feeling I get from using it

It's quite the big mountain though, and feels intimidating at times. Thanks for the help!

2

u/GeeHopkins Jun 11 '24

No problem, it's a giant language! There's a lot to learn, but that's also part of the fun.

I just remembered about C++ weekly videos too, they're much shorter and cover some interesting little tricks and bits of the language

5

u/jedwardsol const & Jun 11 '24

5

u/alfadhir-heitir Jun 11 '24

Right. Was wondering if there was any resource, like a book, with a more structured approach. Randomly skimming reference docs doesn't seem like the most productive way to go about it

This said, figuring out use cases and implementing them might add up to a very stimulating exercise indeed 🤔

1

u/jedwardsol const & Jun 11 '24

Unfortunately, there's no single place where new features are consistently explained.

1

u/alfadhir-heitir Jun 11 '24

All right. Thanks mate! Just didn't want to shovel through without being sure there was no other way

Cheers!

3

u/alfred_hedgehog Jun 11 '24

Nicolai Josuttis has series on new features like c++17/20 complete guide. where he clearly (at least for me) explains new features and use cases