使用 boost C++ 库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4682355/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 16:08:44  来源:igfitidea点击:

Use boost C++ libraries?

c++boost

提问by orlp

Possible Duplicate:
Boost Library

可能重复:
Boost 库

Often when I was trying (and failing) a C++ project I run into Boost when browsing the web. I tried reading the Boost website, but there was no good short description why to use Boost and what it exactly is.

通常,当我尝试(并失败)一个 C++ 项目时,我在浏览网页时会遇到 Boost。我尝试阅读 Boost 网站,但没有很好的简短描述为什么使用 Boost 以及它到底是什么。

One of the things that I like a lot about Python is that everything is built-in and cross-platform, web requests, email, XML, JSON, etc. Is this also the case with Boost?

我非常喜欢 Python 的一件事是,一切都是内置的和跨平台的,Web 请求、电子邮件、XML、JSON 等。 Boost 也是这种情况吗?

So, enough rant, my concrete answer-able questions:

所以,足够的咆哮,我具体的可以回答的问题:

  • What exactly is Boost?
  • What are the most import reasons to use Boost?
  • Is it fully cross-platform?
  • Is it more "safe" then regular home-brew code where you quickly overlook that one buffer overflow, etc?
  • Is there any link to a page describing all the modulesof Boost in one or two sentences?
  • Boost究竟是什么?
  • 使用 Boost 的最重要原因是什么?
  • 它是完全跨平台的吗?
  • 它是否比常规的自制代码更“安全”,您很快就会忽略一个缓冲区溢出等?
  • 是否有任何链接指向用一两句话描述Boost 的所有模块的页面?

回答by Konrad Rudolph

What exactly is Boost?

Boost究竟是什么?

Boost is a collection of useful and extremely high-quality libraries for C++ that complement the rather small standard library.

Boost 是 C++ 的有用且极其高质量的库的集合,它们补充了相当小的标准库。

What are the most import reasons to use Boost?

使用 Boost 的最重要原因是什么?

Boost offers high-quality tools that are missing from C++. Their use is extremely varied though so whether Boost is for you depends entirely on your needs. But I can safely say that everylarge enough C++ code base would benefit from using Boost.

Boost 提供了 C++ 所缺少的高质量工具。它们的用途非常多样化,因此 Boost 是否适合您完全取决于您的需求。但我可以肯定地说,每个足够大的 C++ 代码库都会从使用 Boost 中受益。

Some of the most versatile parts are the shared_ptr(a reference-counting smart pointer that helps prevent memory leaks in pointer-rich code), arraywhich provides a very convenient wrapper around C-style arrays of fixed size and other small odd bits which have been integrated into the next C++ standard.

一些最通用的部分是shared_ptr(一个引用计数智能指针,有助于防止指针丰富的代码中的内存泄漏),array它为固定大小的 C 样式数组和其他已集成的小奇数位提供了一个非常方便的包装器进入下一个 C++ 标准。

Is it fully cross-platform?

它是完全跨平台的吗?

Almost always yes. This is one of the main qualities of Boost.

几乎总是是的。这是 Boost 的主要品质之一。

Is there any link to a page describing all the modules of Boost in one or two sentences?

是否有任何链接指向用一两句话描述 Boost 的所有模块的页面?

There is indeed.

确实有。

回答by Moo-Juice

1) Boost is a set of APIs, developed by some of the best minds in C++. You can use as much or as little a you want. Each API targets, and solves a particular paradigm. For example:

1) Boost 是一组 API,由 C++ 中的一些最优秀的头脑开发。您可以根据需要尽可能多地或尽可能少地使用。每个 API 都针对并解决特定的范例。例如:

lexical_cast<>  - Type-safe ways of casting from one type to another.
program_options - Library for parsing command lines in a type-safe manner
asio            - Asynchronous Input/Output.  Great for working with sockets, IP4/IP6
shared_ptr      - Reference-counted smart pointer

... and many more.

... 还有很多。

2) One of the most important reasons to use Boost is that the great developers that have done this, have, well done it. These solutions are peer-reviewed and robust. If you have a problem to solve and Boost has an API that fits the bill, chances are you should be using it.

2) 使用 Boost 的最重要原因之一是,伟大的开发人员已经做到了,做得很好。这些解决方案经过同行评审且稳健。如果您有一个问题需要解决并且 Boost 有一个符合要求的 API,那么您很有可能应该使用它。

3) It's about as cross-platform as you're going to get. i.e, yes.

3)它与您将要获得的跨平台一样。即,是的。

4) I would use boost over anybody's home-brewed code. Homebrew tends to get used by a single developer (the person that coded it). Boost is in use in commercial applications everywhere and as I said earlier, it's peer-reviewed. You don't get much more robust than that.

4)我会在任何人的自制代码上使用boost。Homebrew 往往被单个开发人员(编码它的人)使用。Boost 在任何地方的商业应用中都有使用,正如我之前所说,它是经过同行评审的。没有比这更强大的了。

5) The main boost page has a list of libraries by function and alphabetically.

5) 主提升页面有一个按功能和字母顺序排列的库列表。

回答by Michael Goldshteyn

What exactly is Boost?

Boost究竟是什么?

Boost is a collection of C++ libraries that help you avoid writing custom code to solve common problems.

Boost 是 C++ 库的集合,可帮助您避免编写自定义代码来解决常见问题。

What are the most important reasons to use Boost?

使用 Boost 的最重要原因是什么?

Boost saves you from having to design, implement and test the solutions it offers. This save you a tremendous amount of time and helps you avoid bugs along the way.

Boost 使您无需设计、实施和测试它提供的解决方案。这为您节省了大量时间,并帮助您在此过程中避免错误。

Is it fully cross-platform?

它是完全跨平台的吗?

Boost supports many platforms, sometimes catering solutions to be efficient on particular platforms. You can see the platforms on which it has been tested, near the bottom of the current version pageunder the Compilers Testedheading.

Boost 支持许多平台,有时会在特定平台上提供高效的解决方案。您可以在Compilers Tested标题下的当前版本页面底部附近看到已对其进行测试的平台。

Is it more "safe" then regular home-brew code where you quickly overlook that one buffer overflow, etc?

它是否比常规的自制代码更“安全”,您很快就会忽略一个缓冲区溢出等?

Yes, unless you have a lot of time to spend testing your code. Boost includes an automated test suite and is tested by hundreds of thousands if not millions of developers via daily usage. It also has a lot of documentation that helps you develop with the libraries it includes. Boost is not only more safe than most home brewed code, it is also, in general, more performant.

是的,除非您有很多时间花在测试代码上。Boost 包括一个自动化测试套件,并通过日常使用由数十万甚至数百万开发人员进行测试。它还有很多文档可以帮助您使用它包含的库​​进行开发。Boost 不仅比大多数自制代码更安全,而且总的来说,它的性能也更高。

Is there any link to a page describing all the modules of Boost in one or two sentences?

是否有任何链接指向用一两句话描述 Boost 的所有模块的页面?

The Boost Library Documentationlinks page offers a one sentence summary of all of the libraries in Boost.

Boost库文档链接页面提供了 Boost 中所有库的一句话总结。

回答by Mark Loeser

Boost is a collection of classes and other things for C++ that are missing from the STL. A lot of the libraries in Boost are being included in the new C++ standard. Its definitely a lot safer than what you'd be able to come up with since this code is widely used and peer reviewed. Its typically full cross-platform, but there may be some gotchas.

Boost 是 STL 中缺少的 C++ 类和其他东西的集合。Boost 中的许多库都包含在新的 C++ 标准中。它绝对比你能想出的安全得多,因为这段代码被广泛使用和同行评审。它通常是完全跨平台的,但可能存在一些问题。

As for what is in boost, check out this: http://www.boost.org/doc/libs/1_45_0/?view=categorized

至于什么是boost,看看这个:http: //www.boost.org/doc/libs/1_45_0/?view=categorized

回答by Tony Delroy

BOOST's a collection of libraries filling needs common to many C++ projects. Generally, they do prioritise correctness, reusability, portability, run-time performance, and space-efficiency over readability of BOOST implementation code, or sometimes compile times. They tend not to cover complete high-level functional requirements (e.g. application frameworks), and instead (thankfully) offer building blocks that can be more freely combined without dictating or dominating the application design.

BOOST 是一组库,可满足许多 C++ 项目的共同需求。一般来说,他们确实优先考虑正确性、可重用性、可移植性、运行时性能和空间效率,而不是 BOOST 实现代码的可读性,有时甚至是编译时间。它们往往不涵盖完整的高级功能需求(例如应用程序框架),而是(值得庆幸的是)提供可以更自由地组合的构建块,而不会支配或支配应用程序设计。

The important reasons to consider using BOOST include:

考虑使用 BOOST 的重要原因包括:

  • most libraries are pretty well tested and designed: they generally get a reasonably sound review by some excellent programmers, compared to by people with home-brew solutions in the same problem space, and widely used enough to gather extensive real-world feedback
  • it's already written and your solution probably isn't
  • it's pretty portable (but that varies per library)
  • more people in the C++ community will have a head-start in helping you with your code
  • BOOST is often a proving ground for introduction to the C++ Standard, so you'll have less work to do in rewriting your code to be compatible with future Standards sans BOOST
  • due to the community demand, compiler vendors are more likely to test and react to issues of correctness with BOOST usage
  • 大多数库都经过了很好的测试和设计:与在同一问题空间中拥有自制解决方案的人相比,它们通常会得到一些优秀程序员的合理评价,并且被广泛使用以收集广泛的现实世界反馈
  • 它已经写好了,你的解决方案可能不是
  • 它非常便携(但每个图书馆都不同)
  • C++ 社区中的更多人将在帮助您编写代码方面处于领先地位
  • BOOST 通常是介绍 C++ 标准的试验场,因此在没有 BOOST 的情况下重写代码以与未来标准兼容的工作量会减少
  • 由于社区需求,编译器供应商更有可能对 BOOST 使用的正确性问题进行测试和反应

The libraries are described in a line or two here: http://www.boost.org/doc/libs/.

这些库在这里用一两行描述:http: //www.boost.org/doc/libs/

回答by tibur

Anything that boost pageon wikipedia doesn't answer?

维基百科上提升页面的任何内容都没有回答?