楼主: ReneeBK
2862 15

Learning Boost C++ Libraries [推广有奖]

  • 1关注
  • 62粉丝

VIP

学术权威

14%

还不是VIP/贵宾

-

TA的文库  其他...

R资源总汇

Panel Data Analysis

Experimental Design

威望
1
论坛币
49407 个
通用积分
51.8104
学术水平
370 点
热心指数
273 点
信用等级
335 点
经验
57815 点
帖子
4006
精华
21
在线时间
582 小时
注册时间
2005-5-8
最后登录
2023-11-26

1论坛币

  • Learning Boost C++ Libraries
  • By: Arindam Mukherjee

  • Publisher: Packt Publishing

  • Pub. Date: July 31, 2015

  • Print ISBN-13: 978-1-78355-121-7

  • Web ISBN-13: 978-1-78355-122-4

  • Pages in Print Edition: 558

  • Subscriber Rating: [0 Ratings]



关键词:libraries Learning earning Aries boost

本帖被以下文库推荐

  • · C++|主题: 253, 订阅: 13
沙发
ReneeBK 发表于 2015-11-9 01:37:09 |只看作者 |坛友微信交流群
  1. How it all started

  2. Sometime around 1997-98, when the draft of the first C++ Standard was being finalized for publication as an ISO/IEC Standard, Robert Klarer from the IBM Labs conceived the idea of a programming language that would be called BOOSE (pronounced "booz"), and which would compete with Java in the area of high-performance embedded software development, which the latter had been aimed at. In a 1998 article for the now defunct C++ Report magazine, C++ guru Herb Sutter wrote a tongue-in-cheek spoof on this new language, whose name ostensibly expanded to Bjarne's Object Oriented Software Environment. In this article, he claimed that portability and potability were, among other things, key advantages of this language, which also supposedly promoted extraordinary camaraderie in team environments and made developers excessively happy, communicative, and passionate.

  3. While this was an April Fools' Day article in 1998, the fact remained that the first C++ Standard was going to have a fairly basic standard library consisting of a memory allocation subsystem, type-generic containers and algorithms, a string class, basic abstractions for input and output devices, and sundry utilities. Now around the same time, a few folks from the C++ Standards Committee formed a group that worked on producing a collection of high-quality, peer-reviewed, free, and open source libraries in C++ that would have wide applicability and complement the features in standard C++. Inspired by BOOSE, perhaps for its stated competition with Java, which was a newer language but with a much richer library, they named this initiative Boost, a working title that stuck (source: FAQ on the Boost website, http://www.boost.org).
复制代码

使用道具

藤椅
ReneeBK 发表于 2015-11-9 01:38:59 |只看作者 |坛友微信交流群
  1. What is Boost?

  2. Boost is a collection of free, peer-reviewed, portable, open source libraries in C++. Over the last decade and a half, there have been, as of this writing, 57 releases of the Boost libraries. In this span, Boost has released libraries of compelling usefulness that promote correct, portable, efficient, and readable C++ code. A number of prominent Standards Committee members are also the most active participants in Boost and subsequent directions of C++ standardization have been heavily influenced by the work done at Boost. Boost has provided the Standards Committee with the laboratory they need to perfect their ideas for the best new features that C++ should have. Several Boost libraries were included in the Technical Report 1 of the C++ Standards Committee, which considerably enhanced the functionality defined in the C++ 2003 revised standard; these included both language and library features. Most of these libraries made it to the C++11 Standard published in 2011. A couple more library features that originated in Boost have been added to the latest revision of the C++ Standard known as C++14 (published in 2014).
复制代码

使用道具

板凳
ReneeBK 发表于 2015-11-9 01:41:21 |只看作者 |坛友微信交流群
  1. Listing 2.1: Using Boost.Optional

  2. 1 #include <string>
  3. 2 #include <map>
  4. 3 #include <boost/optional.hpp>
  5. 4
  6. 5 typedef std::map<std::string, std::string> artiste_album_map;
  7. 6
  8. 7 extern artiste_album_map latest_albums;
  9. 8
  10. 9 boost::optional<std::string> find_latest_album_of(
  11. 10                             const std::string& artiste_name) {
  12. 11   auto iter = latest_albums.find(artiste_name);
  13. 12
  14. 13   if (iter != latest_albums.end()) {
  15. 14     return iter->second;
  16. 15   } else {
  17. 16     return boost::none;
  18. 17   }
  19. 18 }
复制代码

使用道具

报纸
ReneeBK 发表于 2015-11-9 01:42:36 |只看作者 |坛友微信交流群
  1. Listing 2.1: Using Boost.Optional

  2. 1 #include <string>
  3. 2 #include <map>
  4. 3 #include <boost/optional.hpp>
  5. 4
  6. 5 typedef std::map<std::string, std::string> artiste_album_map;
  7. 6
  8. 7 extern artiste_album_map latest_albums;
  9. 8
  10. 9 boost::optional<std::string> find_latest_album_of(
  11. 10                             const std::string& artiste_name) {
  12. 11   auto iter = latest_albums.find(artiste_name);
  13. 12
  14. 13   if (iter != latest_albums.end()) {
  15. 14     return iter->second;
  16. 15   } else {
  17. 16     return boost::none;
  18. 17   }
  19. 18 }
复制代码

使用道具

地板
ReneeBK 发表于 2015-11-9 01:44:40 |只看作者 |坛友微信交流群
  1. Listing 2.2: Generic lookup using optional

  2. 1 #include <boost/optional.hpp>
  3. 2
  4. 3 template <typename C>
  5. 4 boost::optional<typename C::mapped_type>
  6. 5 lookup(const C& dict, const typename C::key_type& key)
  7. 6 {
  8. 7   typename C::const_iterator it = dict.find(key);
  9. 8   if (it != dict.end()) {
  10. 9     return it->second;
  11. 10   } else {
  12. 11     return boost::none;
  13. 12   }
  14. 13 }
复制代码

使用道具

7
ReneeBK 发表于 2015-11-9 01:46:13 |只看作者 |坛友微信交流群
  1. Listing 2.3: Using tuples

  2. 1 #include <boost/tuple/tuple.hpp>
  3. 2 #include <vector>
  4. 3
  5. 4 boost::tuple<size_t, size_t, double>
  6. 5      getBestTransactDays(std::vector<double> prices)
  7. 6 {
  8. 7   double min = std::numeric_limits<double>::max();
  9. 8   double gain = 0.0, max_gain = 0.0;
  10. 9   size_t min_day, max_day;
  11. 10   size_t buy_day;
  12. 11   for (size_t i = 0, days = prices.size(); i < days; ++i) {
  13. 12     if (prices[i] < min) {
  14. 13       min = prices[i];
  15. 14       min_day = i;
  16. 15     } else if ((gain = prices[i] - min) > max_gain) {
  17. 16       max_gain = gain;
  18. 17       buy_day = min_day;
  19. 18       max_day = i;
  20. 19     }
  21. 20   }
  22. 21
  23. 22   return boost::make_tuple(buy_day, max_day, max_gain);
  24. 23 }
复制代码

使用道具

8
neuroexplorer 发表于 2015-11-9 05:33:03 |只看作者 |坛友微信交流群
Learning

使用道具

9
Nicolle 学生认证  发表于 2019-5-26 08:19:48 |只看作者 |坛友微信交流群
提示: 作者被禁止或删除 内容自动屏蔽

使用道具

10
Nicolle 学生认证  发表于 2019-5-26 08:21:07 |只看作者 |坛友微信交流群
提示: 作者被禁止或删除 内容自动屏蔽

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加JingGuanBbs
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-26 14:00