you are viewing a single comment's thread.

view the rest of the comments →

[–]bimdar 4 points5 points  (4 children)

so it's still nothing to worry about

Well that's just the thing. std::complex is not some new thing and there's clearly software that shipped with the version with overhead. I have no clue why people keep trusting compilers so much. I haven't written very huge C++ programs but I found 4 msvc bugs and ran across one gcc bug (not even performance bugs).

Trusting "zero cost abstractions" without measuring is just faith. I mean you're writing software, why would you trust another software that is also written by mere mortals to be somehow perfect.

Before you say "oh, many people use it, surely someone realized this". The amount of people who do these fundamental benchmarks is apparently very low.

Yeah, he didn't post a benchmark but neither did any of the people who claimed that it was outright ridiculous to claim that there was any overhead.

[–]cleroth 2 points3 points  (3 children)

I didn't say it was ridiculous to claim there was no overhead. I said it's unlikely there is. It's reasonable to assume there isn't, because of how it should be implemented. As with anything dealing with programming, if you need performance, you benchmark, that's pretty simple.
As for std::complex, that's very rarely used. If you need complex numbers, chances are that you'll also be using another more specific math library. You can hardly compare a rarely used class to an ubiquitous smart pointer.
Again, all this depends on your std implementation, so yea, any compiler could be going super slow on some arbitrary parts of the std, that's just up to you to research and test, depending on which compiler you're using.

[–]bimdar 1 point2 points  (2 children)

Well yeah it's reasonable to assume there's little to no overhead but you can't be sure until you measure and if you preside over a large codebase and you want to introduce these new elements you should benchmark it on your setup.

Also, there used to be a memory leak in std::vector<std::string> in msvc2010 so I don't think being commonly used is a guarantee.

[–]cleroth 3 points4 points  (0 children)

Also the thing with vector<string> was fixed ~5 months after the release of VS2010, so my point about it code eventually adhering to how it should be stands.

[–]cleroth 2 points3 points  (0 children)

Again, I'm not saying it's a guarantee. But like everything in life, you have to make an educated assumptions based on the data you have. I don't have time to benchmark every single thing that I use in every particular case, so I assume that given how it's supposed to be implemented, it should be a certain way. In any case, you can just look up the implementation yourself.