SlideShare uma empresa Scribd logo
1 de 13
Baixar para ler offline
Boostライブラリ一周の旅
            ver.1.50.0




        高橋晶(Akira Takahashi)
            id:faith_and_brave
                    @cpp_akira

           Boost.勉強会#10 2012/07/28(土)
はじめに

この発表は、Boostのなるべく全てのライブラリを紹介して
いこうという企画です。
毎回、これまでの差分を紹介し、全体にマージした資料を
同時に公開しています。

前回は、Boost 1.48.0までのライブラリを紹介しました。
今回は1.49.0と1.50.0で追加されたライブラリを紹介して
いきます。
Boostとは
• C++標準化委員会の人たちが作ったC++のライブラリ群

• 普段のプログラミング全般で使える基本的なものから、専門
  特化したものまでいろいろなライブラリがある

• Google、Intel、Adobeも開発に関わっている

• ライセンスはBoost Software License 1.0
  – 無償で商用利用可能
  – 著作権表記の必要なし
  – ソースコードの改変自由
本日紹介するライブラリ


1. Heap
2. Algorithm
3. Functional/OverloadedFunction
4. LocalFunction
5. Utility/IdentityType
Heap 1/2
優先順位付きキューのデータ構造

boost::heap::fibonacci_heap<int> que; // フィボナッチヒープ

que.push(3);
que.push(1);
que.push(4);

while (!que.empty()) {
    std::cout << que.top() << std::endl;
    que.pop();
}


4
3
1
Heap 2/2
Boost.Heapの特徴:

•   要素の修正ができる (Mutability)
•   イテレータを持っている (Iterators)
•   マージできる (Mergable)
•   安定 (Stability)
Algorithm 1/3
アルゴリズム集。文字列検索、C++11アルゴリズム、
ユーティリティが含まれる
std::string text =
   "the stick, and made believe to worry it: then Alice dodged behind a";
std::string pattern = "behind";

// BM法で文字列検索
decltype(text)::const_iterator it =
   boost::algorithm::boyer_moore_search(text.begin(), text.end(),
                                        pattern.begin(), pattern.end());

if (it != text.end()) std::cout << "found" << std::endl;
else                  std::cout << "not found" << std::endl;

found
Algorithm 2/3
アルゴリズム集。文字列検索、C++11アルゴリズム、
ユーティリティが含まれる
const std::vector<int> v = {2, 4, 6, 8, 10};

// 全ての値が偶数かを調べる
bool result = boost::algorithm::all_of(v, is_even);

std::cout << std::boolalpha << result << std::endl;


true
Algorithm 3/3
アルゴリズム集。文字列検索、C++11アルゴリズム、
ユーティリティが含まれる
using boost::algorithm::clamp;

// xを0~10の範囲に丸める : min(max(a, x), b)

int x = 11;
x = clamp(x, 0, 10); // x == 10

int y = -1;
y = clamp(y, 0, 10); // x == 0
Functional/OverloadedFunction
複数の関数から、オーバーロードする
関数オブジェクトを作る。
const std::string& identity_s(const std::string& s) { return s; }
int identity_n(int x)                               { return x; }
double identity_d(double x)                         { return x; }

boost::overloaded_function<
    const std::string& (const std::string&),
    int (int),
    double (double)
> identity(identity_s, identity_n, identity_d);

std::string s = "hello"; s = identity(s);
int n = 2;               n = identity(n);
double d = 3.14;         d = identity(d);
Local Function
ローカル関数を定義する
int main()
{
    int sum = 0;

     void BOOST_LOCAL_FUNCTION(bind& sum, int x) {
         sum += x;
     } BOOST_LOCAL_FUNCTION_NAME(add);

     const std::vector<int> v = {1, 2, 3, 4, 5};
     boost::for_each(v, add);

     std::cout << sum << std::endl;
}

15
Utility/IdentityType
関数マクロに渡す引数でカンマを付けれるようにする
std::map<int, int> m = {{1, 3}, {2, 4}};

BOOST_FOREACH(
  BOOST_IDENTITY_TYPE((std::map<int, int>))::const_reference x, m) {
    std::cout << x.first << "," << x.second << std::endl;
}



1,3
2,4
まとめ(?)

• まとめはとくにありません。

• ここでは差分のみを紹介しましたが、1.50.0までのライブラリ
  をまとめたスライドも別途用意しています。
  全体を知りたい方はそちらを参照してください。

Boostライブラリ一周の旅 1.50.0(all)
http://www.slideshare.net/faithandbrave/boost-tour-1480-all

Mais conteúdo relacionado

Mais procurados

String representation in py3k
String representation in py3kString representation in py3k
String representation in py3kAtsuo Ishimoto
 
Python で munin plugin を書いてみる
Python で munin plugin を書いてみるPython で munin plugin を書いてみる
Python で munin plugin を書いてみるftnk
 
PHP5.5新機能「ジェネレータ」初心者入門
PHP5.5新機能「ジェネレータ」初心者入門PHP5.5新機能「ジェネレータ」初心者入門
PHP5.5新機能「ジェネレータ」初心者入門kwatch
 
Python 3.6 リリースパーティー 発表資料
Python 3.6 リリースパーティー 発表資料Python 3.6 リリースパーティー 発表資料
Python 3.6 リリースパーティー 発表資料Atsuo Ishimoto
 
Google Developer Day 2010 Japan: プログラミング言語 Go (鵜飼 文敏)
Google Developer Day 2010 Japan: プログラミング言語 Go (鵜飼 文敏)Google Developer Day 2010 Japan: プログラミング言語 Go (鵜飼 文敏)
Google Developer Day 2010 Japan: プログラミング言語 Go (鵜飼 文敏)Google Developer Relations Team
 
STLの型の使い分け(ダイジェスト版) @ Sapporo.cpp 第7回勉強会 (2014.10.18)
STLの型の使い分け(ダイジェスト版) @ Sapporo.cpp 第7回勉強会 (2014.10.18)STLの型の使い分け(ダイジェスト版) @ Sapporo.cpp 第7回勉強会 (2014.10.18)
STLの型の使い分け(ダイジェスト版) @ Sapporo.cpp 第7回勉強会 (2014.10.18)Hiro H.
 
C++のSTLのコンテナ型を概観する @ Ohotech 特盛 #10(2014.8.30)
C++のSTLのコンテナ型を概観する @ Ohotech 特盛 #10(2014.8.30)C++のSTLのコンテナ型を概観する @ Ohotech 特盛 #10(2014.8.30)
C++のSTLのコンテナ型を概観する @ Ohotech 特盛 #10(2014.8.30)Hiro H.
 
Garageをもうちょっと触ってみた
Garageをもうちょっと触ってみたGarageをもうちょっと触ってみた
Garageをもうちょっと触ってみたYoichi Toyota
 
traitを使って楽したい話
traitを使って楽したい話traitを使って楽したい話
traitを使って楽したい話infinite_loop
 
2011.12.10 関数型都市忘年会 発表資料「最近書いた、関数型言語と関連する?C++プログラムの紹介」
2011.12.10 関数型都市忘年会 発表資料「最近書いた、関数型言語と関連する?C++プログラムの紹介」2011.12.10 関数型都市忘年会 発表資料「最近書いた、関数型言語と関連する?C++プログラムの紹介」
2011.12.10 関数型都市忘年会 発表資料「最近書いた、関数型言語と関連する?C++プログラムの紹介」Hiro H.
 
Introduction to cython
Introduction to cythonIntroduction to cython
Introduction to cythonAtsuo Ishimoto
 

Mais procurados (20)

Boost tour 1_40_0
Boost tour 1_40_0Boost tour 1_40_0
Boost tour 1_40_0
 
Subprocess no susume
Subprocess no susumeSubprocess no susume
Subprocess no susume
 
String representation in py3k
String representation in py3kString representation in py3k
String representation in py3k
 
Mock and patch
Mock and patchMock and patch
Mock and patch
 
Python で munin plugin を書いてみる
Python で munin plugin を書いてみるPython で munin plugin を書いてみる
Python で munin plugin を書いてみる
 
boost tour 1.48.0 all
boost tour 1.48.0 allboost tour 1.48.0 all
boost tour 1.48.0 all
 
Nginx lua
Nginx luaNginx lua
Nginx lua
 
PHP5.5新機能「ジェネレータ」初心者入門
PHP5.5新機能「ジェネレータ」初心者入門PHP5.5新機能「ジェネレータ」初心者入門
PHP5.5新機能「ジェネレータ」初心者入門
 
Python 3.6 リリースパーティー 発表資料
Python 3.6 リリースパーティー 発表資料Python 3.6 リリースパーティー 発表資料
Python 3.6 リリースパーティー 発表資料
 
Google Developer Day 2010 Japan: プログラミング言語 Go (鵜飼 文敏)
Google Developer Day 2010 Japan: プログラミング言語 Go (鵜飼 文敏)Google Developer Day 2010 Japan: プログラミング言語 Go (鵜飼 文敏)
Google Developer Day 2010 Japan: プログラミング言語 Go (鵜飼 文敏)
 
C++14 Overview
C++14 OverviewC++14 Overview
C++14 Overview
 
STLの型の使い分け(ダイジェスト版) @ Sapporo.cpp 第7回勉強会 (2014.10.18)
STLの型の使い分け(ダイジェスト版) @ Sapporo.cpp 第7回勉強会 (2014.10.18)STLの型の使い分け(ダイジェスト版) @ Sapporo.cpp 第7回勉強会 (2014.10.18)
STLの型の使い分け(ダイジェスト版) @ Sapporo.cpp 第7回勉強会 (2014.10.18)
 
Teclab3
Teclab3Teclab3
Teclab3
 
PHP7を魔改造した話
PHP7を魔改造した話PHP7を魔改造した話
PHP7を魔改造した話
 
C++のSTLのコンテナ型を概観する @ Ohotech 特盛 #10(2014.8.30)
C++のSTLのコンテナ型を概観する @ Ohotech 特盛 #10(2014.8.30)C++のSTLのコンテナ型を概観する @ Ohotech 特盛 #10(2014.8.30)
C++のSTLのコンテナ型を概観する @ Ohotech 特盛 #10(2014.8.30)
 
Garageをもうちょっと触ってみた
Garageをもうちょっと触ってみたGarageをもうちょっと触ってみた
Garageをもうちょっと触ってみた
 
traitを使って楽したい話
traitを使って楽したい話traitを使って楽したい話
traitを使って楽したい話
 
CLR/H No.35-2
CLR/H No.35-2CLR/H No.35-2
CLR/H No.35-2
 
2011.12.10 関数型都市忘年会 発表資料「最近書いた、関数型言語と関連する?C++プログラムの紹介」
2011.12.10 関数型都市忘年会 発表資料「最近書いた、関数型言語と関連する?C++プログラムの紹介」2011.12.10 関数型都市忘年会 発表資料「最近書いた、関数型言語と関連する?C++プログラムの紹介」
2011.12.10 関数型都市忘年会 発表資料「最近書いた、関数型言語と関連する?C++プログラムの紹介」
 
Introduction to cython
Introduction to cythonIntroduction to cython
Introduction to cython
 

Destaque

Joe, Artie, Shane
Joe, Artie, ShaneJoe, Artie, Shane
Joe, Artie, ShaneSoldierX
 
Kelompok pjk presentasi
Kelompok pjk presentasiKelompok pjk presentasi
Kelompok pjk presentasihalimeee
 
Contrast enhanced spectral mammography
Contrast enhanced spectral mammographyContrast enhanced spectral mammography
Contrast enhanced spectral mammographyRadiology Archives
 

Destaque (6)

Joe, Artie, Shane
Joe, Artie, ShaneJoe, Artie, Shane
Joe, Artie, Shane
 
Enlace químico II
Enlace químico IIEnlace químico II
Enlace químico II
 
Anthony
AnthonyAnthony
Anthony
 
Eeeee
EeeeeEeeee
Eeeee
 
Kelompok pjk presentasi
Kelompok pjk presentasiKelompok pjk presentasi
Kelompok pjk presentasi
 
Contrast enhanced spectral mammography
Contrast enhanced spectral mammographyContrast enhanced spectral mammography
Contrast enhanced spectral mammography
 

Semelhante a Boost Tour 1.50.0

C++0xの概要(デブサミ2010)
C++0xの概要(デブサミ2010)C++0xの概要(デブサミ2010)
C++0xの概要(デブサミ2010)Akira Takahashi
 
Replace Output Iterator and Extend Range JP
Replace Output Iterator and Extend Range JPReplace Output Iterator and Extend Range JP
Replace Output Iterator and Extend Range JPAkira Takahashi
 
2018/06/23 Sony"s deep learning software and the latest information
2018/06/23 Sony"s deep learning software and the latest information2018/06/23 Sony"s deep learning software and the latest information
2018/06/23 Sony"s deep learning software and the latest informationSony Network Communications Inc.
 
SystemC Tutorial
SystemC TutorialSystemC Tutorial
SystemC Tutorialkocha2012
 
TypeScript と Visual Studio Code
TypeScript と Visual Studio CodeTypeScript と Visual Studio Code
TypeScript と Visual Studio CodeAkira Inoue
 
C++0x in programming competition
C++0x in programming competitionC++0x in programming competition
C++0x in programming competitionyak1ex
 
Continuation with Boost.Context
Continuation with Boost.ContextContinuation with Boost.Context
Continuation with Boost.ContextAkira Takahashi
 
Boost.勉強会 #21 札幌「C++1zにstring_viewが導入されてうれしいので紹介します」
Boost.勉強会 #21 札幌「C++1zにstring_viewが導入されてうれしいので紹介します」Boost.勉強会 #21 札幌「C++1zにstring_viewが導入されてうれしいので紹介します」
Boost.勉強会 #21 札幌「C++1zにstring_viewが導入されてうれしいので紹介します」Hiro H.
 
Learning Template Library Design using Boost.Geomtry
Learning Template Library Design using Boost.GeomtryLearning Template Library Design using Boost.Geomtry
Learning Template Library Design using Boost.GeomtryAkira Takahashi
 
Boost jp9 program_options
Boost jp9 program_optionsBoost jp9 program_options
Boost jp9 program_optionsnyaocat
 
ぱっと見でわかるC++11
ぱっと見でわかるC++11ぱっと見でわかるC++11
ぱっと見でわかるC++11えぴ 福田
 
Impractical Introduction of Boost Spirit Qi [PPT]
Impractical Introduction of Boost Spirit Qi [PPT]Impractical Introduction of Boost Spirit Qi [PPT]
Impractical Introduction of Boost Spirit Qi [PPT]yak1ex
 

Semelhante a Boost Tour 1.50.0 (20)

Boost Tour 1.53.0 merge
Boost Tour 1.53.0 mergeBoost Tour 1.53.0 merge
Boost Tour 1.53.0 merge
 
Boost Fusion Library
Boost Fusion LibraryBoost Fusion Library
Boost Fusion Library
 
Boost Tour 1.53.0
Boost Tour 1.53.0Boost Tour 1.53.0
Boost Tour 1.53.0
 
Study3 boost
Study3 boostStudy3 boost
Study3 boost
 
C++0xの概要(デブサミ2010)
C++0xの概要(デブサミ2010)C++0xの概要(デブサミ2010)
C++0xの概要(デブサミ2010)
 
Replace Output Iterator and Extend Range JP
Replace Output Iterator and Extend Range JPReplace Output Iterator and Extend Range JP
Replace Output Iterator and Extend Range JP
 
2018/06/23 Sony"s deep learning software and the latest information
2018/06/23 Sony"s deep learning software and the latest information2018/06/23 Sony"s deep learning software and the latest information
2018/06/23 Sony"s deep learning software and the latest information
 
SystemC Tutorial
SystemC TutorialSystemC Tutorial
SystemC Tutorial
 
TypeScript と Visual Studio Code
TypeScript と Visual Studio CodeTypeScript と Visual Studio Code
TypeScript と Visual Studio Code
 
C++0x in programming competition
C++0x in programming competitionC++0x in programming competition
C++0x in programming competition
 
Boost Tour 1.50.0 All
Boost Tour 1.50.0 AllBoost Tour 1.50.0 All
Boost Tour 1.50.0 All
 
Pfi Seminar 2010 1 7
Pfi Seminar 2010 1 7Pfi Seminar 2010 1 7
Pfi Seminar 2010 1 7
 
Continuation with Boost.Context
Continuation with Boost.ContextContinuation with Boost.Context
Continuation with Boost.Context
 
Prosym2012
Prosym2012Prosym2012
Prosym2012
 
Boost.勉強会 #21 札幌「C++1zにstring_viewが導入されてうれしいので紹介します」
Boost.勉強会 #21 札幌「C++1zにstring_viewが導入されてうれしいので紹介します」Boost.勉強会 #21 札幌「C++1zにstring_viewが導入されてうれしいので紹介します」
Boost.勉強会 #21 札幌「C++1zにstring_viewが導入されてうれしいので紹介します」
 
Learning Template Library Design using Boost.Geomtry
Learning Template Library Design using Boost.GeomtryLearning Template Library Design using Boost.Geomtry
Learning Template Library Design using Boost.Geomtry
 
Boost tour 1_44_0
Boost tour 1_44_0Boost tour 1_44_0
Boost tour 1_44_0
 
Boost jp9 program_options
Boost jp9 program_optionsBoost jp9 program_options
Boost jp9 program_options
 
ぱっと見でわかるC++11
ぱっと見でわかるC++11ぱっと見でわかるC++11
ぱっと見でわかるC++11
 
Impractical Introduction of Boost Spirit Qi [PPT]
Impractical Introduction of Boost Spirit Qi [PPT]Impractical Introduction of Boost Spirit Qi [PPT]
Impractical Introduction of Boost Spirit Qi [PPT]
 

Mais de Akira Takahashi (20)

Cpp20 overview language features
Cpp20 overview language featuresCpp20 overview language features
Cpp20 overview language features
 
Cppmix 02
Cppmix 02Cppmix 02
Cppmix 02
 
Cppmix 01
Cppmix 01Cppmix 01
Cppmix 01
 
Modern C++ Learning
Modern C++ LearningModern C++ Learning
Modern C++ Learning
 
cpprefjp documentation
cpprefjp documentationcpprefjp documentation
cpprefjp documentation
 
C++1z draft
C++1z draftC++1z draft
C++1z draft
 
Boost tour 1_61_0 merge
Boost tour 1_61_0 mergeBoost tour 1_61_0 merge
Boost tour 1_61_0 merge
 
Boost tour 1_61_0
Boost tour 1_61_0Boost tour 1_61_0
Boost tour 1_61_0
 
error handling using expected
error handling using expectederror handling using expected
error handling using expected
 
Boost tour 1.60.0
Boost tour 1.60.0Boost tour 1.60.0
Boost tour 1.60.0
 
Boost container feature
Boost container featureBoost container feature
Boost container feature
 
Boost Tour 1_58_0
Boost Tour 1_58_0Boost Tour 1_58_0
Boost Tour 1_58_0
 
C++14 solve explicit_default_constructor
C++14 solve explicit_default_constructorC++14 solve explicit_default_constructor
C++14 solve explicit_default_constructor
 
C++14 enum hash
C++14 enum hashC++14 enum hash
C++14 enum hash
 
Multi paradigm design
Multi paradigm designMulti paradigm design
Multi paradigm design
 
Start Concurrent
Start ConcurrentStart Concurrent
Start Concurrent
 
Programmer mind
Programmer mindProgrammer mind
Programmer mind
 
Boost.Study 14 Opening
Boost.Study 14 OpeningBoost.Study 14 Opening
Boost.Study 14 Opening
 
Executors and schedulers
Executors and schedulersExecutors and schedulers
Executors and schedulers
 
Improvement future api
Improvement future apiImprovement future api
Improvement future api
 

Boost Tour 1.50.0