C ++标准库

编程入门 行业动态 更新时间:2024-10-10 10:28:53
本文介绍了C ++标准库 - 当我应该使用它,什么时候不应该吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想知道多久人们实际使用多少的标准的C ++库,特别是在&LT的东西;算法> 和<数字&GT ; 头。教科书似乎推荐他们,但我还没有看到任何人使用在所有的我已经通过筛选各种项目(巧合?),并亲自它似乎更容易只是每次写适当的简单的算法我自己,而不是背诵或请教每次提到这些报头。我只是懒惰或固执?有没有实际使用这些库时,性能提升等?

I was wondering how often people actually use much of the standard c++ library, particularly the stuff in the <algorithm> and <numeric> headers. The text books seem to recommend them, but I haven't seen any of them used at all in various projects I've sifted through (coincidence?) and personally it seems easier to just write appropriate simple algorithms myself each time rather than memorize or consult a reference to these headers each time. Am just being lazy or stubborn? Is there actually performance gains etc when using these libraries?

谢谢

研究

推荐答案

这是可能你懒惰或固执。就个人而言,我使用他们生产code所有的时间。

It's possible you're being lazy or stubborn. Personally, I use them all the time in production code.

我不这样做,是看中了,因为我喜欢写我不这样做太空时代的code。相反,我这样做是因为我是一个偏执的程序员,我知道,生产环境是充满敌意的地方,这将毁坏code和减少我的计划,吸烟毫无价值的字节桩,如果有机会。

I don't do this to be fancy, and I don't do this because I like writing "space-age code." Rather, I do this because I am a paranoid programmer, and I know that production environments are hostile places that will mutilate code and reduce my programs to smoking piles of worthless bytes, if given a chance.

我这样做是因为我生活的座右铭,最好的code,是code,你从来不写。这需要时间来学习如何使用STL和放大器;标准库的有效的,但一旦你做,你会发现,它可以用来使什么现在是1000行code成为可能100这100个可能需要长达写的原来1000,但有较少的故障点。在code可以是更强大的,如果你站在别人的肩膀上。

I do this because I live by the motto, "The best code, is the code you never write." It takes time to learn how to use the STL & Std Lib effectively, but once you do you'll find that it can be used so that what now is 1000 lines of code becomes perhaps 100. Those 100 might take as long to write as the original 1000, but there are fewer failure points. The code can be more robust, if you stand on the shoulders of others.

更多推荐

C ++标准库

本文发布于:2023-11-13 10:51:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584172.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标准

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!