C should i use stl




















Aka "don't use it when you don't have it", which makes sense, really. JanHudec I believe there are platforms without STL because they don't have enough memory to handle the whole thing. Sulthan: For microcontrollers I kind of understand, but those fall in the "hard realtime" category usually. For anything else, that's mostly preconceptions, because STL is usually just as efficient both memory and performance-wise as hand-crafted code.

Lot of inlining may cause larger binary, but that could even be avoided by careful implementation at some performance cost that a hand-crafted solution would have too. Missing exceptions are also either preconception, or laziness, because it takes effort to define and implement the exception ABI. So, it can be practical to abandon the STL if you can use another library that fits your needs.

Giorgio Giorgio 19k 16 16 gold badges 78 78 silver badges bronze badges. That's the only reason they are still used, nothing against the STL of today. In general I would advise to use the STL libraries if possible because they are standard. The question being asked is if it is possible to use other libraries and Qt is such an alternative. Giorgio: the problem is in complex applications, where you're combining multiple libraries.

The STL containers, being standard, form a lingua franca. More precisely, it's their conventions which do. The best-known example is Boost. It can work on STL containers. I didn't downvote it, but I see one reason: It's does not answer the question. NoOne: We get that you are used to camelcase, not snakecase, but that doesn't make the latter any worse.

And of the three function-names you criticize, the first is perfectly descriptive for anyone having anything to do with c-strings, and the other two are inherited from C, won't discuss those. Show 8 more comments. I would imagine every successful game starts by writing code using the standard library and then only optimising code once the game has been extensively profiled. Optimising before you have profiling data stating what needs optimising is pointless.

Perhaps I should've made it more clear. It should be said, that it's more of an old experience living on. Skip to content. Change Language. Related Articles. Table of Contents.

Save Article. Improve Article. Like Article. Output Initial vector: 1 2 3 4 5 6 7 8 9 10 Vector size: 10 Is vector is empty: False Vector after popping: 1 2 3 4 5 6 7 8 9 Vector after erase first element: 2 3 4 5 6 7 8 9 Vector after clearing: None Is vector is empty: True.

Previous Check if given Binary string follows then given condition or not. Next Lexicographical smallest number after at most K consecutive swaps. Recommended Articles. Article Contributed By :. Easy Normal Medium Hard Expert. Writing code in comment? Please use ide. Load Comments. Have you checked the uSTL? Looks good, thanks. I need to delve deeper into portability, of course. You can have complete control over the memory, quite easily.

Add a comment. Active Oldest Votes. Brian Neal Brian Neal But I don't think you know as much about exceptions or code bloat as you think you do -- please see my comments in response to yours on others' posts. Where exactly in my response does the phrase "code bloat" appear? What sort of processors do you target? Are you allowed to use Boost yet? Dan Olson Dan Olson Thanks, Dan, this and others also voted up made me actually think.

Since we have an embedded system, we have our own memory pool. STL is useful to us mostly for container classes; but we max them at initialization time. It's a detailed article, but the most important reasons were: STL allocators are slow, bloated, and inefficient Compilers aren't actually very good at inlining all those deep function calls STL allocators don't support explicit alignment The STL algorithms that come with GCC and MSVC's STL aren't very performant, because they're very platform-agnostic and thus miss a lot of microoptimizations that can make a big difference.

Crashworks Crashworks You've linked an article from which is now out of date. If you're dealing with an embedded system for which a decent modern copmiler doesn't exist you have a problem - but to give a blanket "As to exceptions: they are slow" is flat out wrong. If you don't use exceptions, you yourself are now responsible for writing and checking error return codes, and this code is almost always less efficient and compared to the code modern compilers emit for exceptions.

Furthermore, the code people write if they bother to write it at all to check error codes is often rife with errors and mistakes. To see this, try compiling not linking pastebin.

In both cases, Win32 structured exception handling SEH management is introduced -- that's the additional pushing of data onto the stack and setting of the FS segment register. The article is from , but my own timings were from August I have read all the theory about how exceptions aren't slow any more but they do not corroborate with actual measurements I have taken.

Brian: those are EA's points, not mine, but 4 was determined empirically. Basically, they wrote their own implementations of the containers, and found that they ran much faster than the STL's. Therefore, the STL is not maximally efficient. Show 2 more comments. Mark Ransom Mark Ransom k 40 40 gold badges silver badges bronze badges. What do you mean "the STL doesn't throw exceptions on its own"?

What if you call vector::at with an out of range index? And you can also configure IO streams to throw exceptions. Also, templates can generate more code than you may if you wrote it by hand. Brian: vector::at is a good example. It would be more accurate to say that the STL can be used in such a way that it will never generate exceptions here, by using operator[] instead of at and without making any additional compromises.

Update cgmanifest. Git stats commits. Failed to load latest commit information. Compile TypeScript in update-status-chart. Oct 20, Aug 27, Toolset update: VS Nov 3, Update LLVM submodule reference Feb 2, Sep 25, Jul 20, Mar 4, Oct 30, Initial commit.

Sep 4, Apr 15, View code. Our Changelog tracks which updates to this repository appear in each VS release. Our Status Chart displays our overall progress over time. Join our Discord server. Current status: Code: Done. Our primary goals are conformance, performance, usability, and compatibility. Non-Goals There are things that we aren't interested in doing with this project, for various reasons most importantly, we need to focus development effort on our goals. Some examples: Non-goal: Porting to other platforms.

Non-goal: Adding non-Standard extensions. Please help us efficiently process bug reports by following these rules: Only STL bugs should be reported here. This will ensure that you're using supported versions of CMake and Ninja. Otherwise, install CMake 3. We recommend selecting "Python 3 bit" in the VS Installer. Otherwise, make sure Python 3. Open Visual Studio, and choose the "Clone or check out code" option.

In the terminal, invoke git submodule update --init --progress llvm-project boost-math Choose the architecture you wish to build in the IDE, and build as you would any other project. Open a command prompt. Change directories to a location where you'd like a clone of this STL repository.



0コメント

  • 1000 / 1000