r/cpp • • Dec 17 '23

Cpp std features and tech domains

Hello fello C++ developers!

I been reading a lot this sub and it always comes to the conversation that the std have a lot of things, and that you are expected to learn what its related to your tech domain.

So here is my question:

What parts of the std do you link to what domains?

If you were to recommend someone that aims to build servers what they should start learning, what would you suggest? Why?

Same for other domains ofc, I'm curious on how the experience and language features varies per domain and usage, and how you find out what you need or where to search for it.

Edit: it seems that my question was not laid out correctly.

Im not asking specifically about server stuff for my line of work, I'm asking about yours.

So, what do you do? What parts of C++ do you use? Why those?

Sorry if my initial post was unclear!

0 Upvotes

13 comments sorted by

View all comments

2

u/rhubarbjin Dec 18 '23 edited Dec 18 '23

I work in gamedev. Our company has a strict no-STL policy for anything that would allocate memory (e.g., std::sort is fine, std::vector is not).

We ship on multiple platforms where memory allocations must be carefully managed. The STL's allocator infra was deemed insufficient, so the team opted for an in-house library instead.

(I'm merely describing the situation as it is. I'm not judging whether or not that was the correct decision; it was many years before I joined and it would be above my level anyway.)

Fancier stuff (filesystem, network, threads, etc.) is off-limits too. Those need to go through each platform's proprietary API.

2

u/antara33 Dec 18 '23

Thanks for the insight! Since you dont use STL, what parts of the language are most valuable to your use case?

If you were free to use anything from it, what parts of the STL would you take and why?

Are the newer features for latest drafts of any use for you? (in the broad context of being able to use STL entirely)

1

u/rhubarbjin Dec 19 '23 edited Dec 19 '23

For context, we recently (a few months ago) switched from C++14 to C++17.

what parts of the language are most valuable to your use case?

In my experience, gamedevs are a very "conservative" bunch. My colleagues rarely venture outside of basic RAII. That said, in the last year there's been a wave of "new blood" entering the team and with them I've seen more modern patterns creeping into the codebase:

  • a multithreaded task library that make heavy use of lambda expressions

  • strong types instead of integer IDs

  • a generic "scope guard" helper, also leveraging lambdas + RAII

  • less reliance on run-time asserts, more reliance on compile-time errors

what parts of the STL would you take and why?

I can't think of anything, really. If there's a STL feature we need, we "port" it to our in-house library.

Are the newer features for latest drafts of any use for you?

  • The thing I'm looking forward the most is designated initializers. Huge improvement to code clarity!

  • I'm keeping an eye on coroutines. I don't fully grok how they work in C++, but the concept (a function that can suspend its execution) sounds like it could be useful for time-slicing CPU-bound tasks.

  • Default comparisons. I spend way too much time writing operator == boilerplate for my structs.

  • Reflection would be wonderful (though I've lost hope that it will be standardized before I enter retirement 😜). We have an in-house QT-like parser that extracts a few type traits, but it's limited and annoying to use.