Skip to content

Commit df00944

Browse files
committed
1 parent 2fbc670 commit df00944

File tree

6 files changed

+328
-55
lines changed

6 files changed

+328
-55
lines changed

000_working_list.md

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,14 @@ https://www.boost.org/doc/libs/1_72_0/doc/html/stacktrace.html
1313
https://www.boost.org/doc/libs/1_72_0/libs/vmd/doc/html/index.html
1414
https://www.boost.org/doc/libs/1_72_0/doc/html/yap.html
1515

16-
17-
16+
1817
boost stack trace
1918
https://theolizer.com/cpp-school2/cpp-school2-28/
2019
https://theolizer.com/cpp-school2/cpp-school2-29/
2120
https://theolizer.com/cpp-school2/cpp-school2-31/
2221

23-
24-
参照を保持するコンテナ http://faithandbrave.hateblo.jp/entry/20110519/1305789940
25-
boost::in_place http://nekko1119.hatenablog.com/entry/20121122/1353577143
26-
プラグインシステムを Boost.DLL で簡単に実装する紹介 http://qiita.com/usagi/items/0722550dc5433bd07139
27-
28-
29-
30-
22+
23+
3124
##TypeErasure
3225
Boost.TypeErasure を使ってみる http://d.hatena.ne.jp/osyo-manga/20121202/1354456126
3326
Boost.TypeErasureのドキュメントを翻訳してみた http://d.hatena.ne.jp/gununu/20130705/1372983790
@@ -83,35 +76,7 @@ Try to use boost.mpl http://www.slideshare.net/Suikaba/try-to-use-boostmpl
8376
## wave
8477
http://www.ruche-home.net/program/boost/wave
8578

86-
## Boost.Context
87-
Boost.Context について調べた http://d.hatena.ne.jp/melpon/20111213/1323704464
88-
89-
Continuation with Boost.Context http://www.slideshare.net/faithandbrave/continuation-with-boostcontext
90-
91-
Boost.Context 非同期?理を逐次的にする http://d.hatena.ne.jp/faith_and_brave/20120329/1333008572
92-
93-
boost.contextを使ってみました http://d1z.cocolog-nifty.com/blog/2012/02/boostcontext-ac.html
94-
95-
Boost.Contextでファイバ?ライブラリを??してみた http://yohhoy.hatenablog.jp/entry/2012/04/10/003735
96-
97-
98-
Coroutine , fiber 実行コンテキストの抽象化ライブラリ達
99-
http://www.flast.jp/article/boost-21-sapporo/index.html
100-
http://www.flast.jp/article/boost-21-sapporo/execution.html
101-
102-
Boost.Coroutineのローカル変数の寿命 http://d.hatena.ne.jp/y_mazun/20130205/1360077844
103-
104-
Boost.Coroutine でフィボナッチ http://d.hatena.ne.jp/osyo-manga/20130209/1360412742
105-
106-
Boost.Coroutine http://d.hatena.ne.jp/joynote/20131118/1384779314
107-
108-
C++ のコルーチン boost::coroutines を使ってみる http://qiita.com/kobake@github/items/506b5ff128dc1372cd1d
109-
110-
C++14 & boost::{coroutines|signals2} -> yieldable task system http://qiita.com/usagi/items/6dad042e20ef1fe9f91c
111-
112-
Visual C++ CoroutineとBoost Coroutine http://sayurin.blogspot.kr/2016/07/visual-c-coroutineboost-coroutine_9.html
113-
114-
79+
11580

11681
## Algorithm
11782
Algorithm clamp
@@ -188,22 +153,6 @@ Boost.Fusionでreplicate http://d.hatena.ne.jp/faith_and_brave/20120720/1342768
188153
Type Driven Wire Protocols with Boost Fusion http://rodgert.github.io/2014/09/09/type-driven-wire-protocols-with-boost-fusion-pt1/
189154

190155

191-
192-
## boost::signals2
193-
튜토리얼 http://docs.google.com/Doc?id=ddcwmgjq_12hdhr8tcw
194-
boostjp https://sites.google.com/site/boostjp/tips/signals
195-
boost::signals2 が便利そうな件について http://d.hatena.ne.jp/gintenlabo/20091201/1259671954
196-
Observerパタ?ン http://w.livedoor.jp/programming/d/Signals2
197-
Boost.Signals2 切? http://d.hatena.ne.jp/faith_and_brave/20110131/1296458381
198-
Boost.Signals2 を Boost.Parameter を使用して定義する http://d.hatena.ne.jp/osyo-manga/20110816/1313449833
199-
Boost.Signals2 で呼ばれる??に優先順位を付ける http://d.hatena.ne.jp/osyo-manga/20110815/1313366926
200-
デリゲ?トまたはイベントハンドラをC++で??するならBoost.FunctionよりもBoost.Signals2を使おう。 http://d.hatena.ne.jp/poyonon/20111110/1320933772
201-
C++ で、Model-View-Controller とか http://d.hatena.ne.jp/osyo-manga/20110721/1311240737
202-
シグナル・スロット(Signal/Slot)の仕組みをBoost.Signal2で試してみる http://qiita.com/kaoru/items/b8b39899ee4c771c2518
203-
boost::signals2 http://nekko1119.hatenablog.com/entry/20121108/1352356571
204-
205-
206-
207156
## QVM
208157
행열 계산 라이브러리.
209158

Context.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Boost.Context
2+
Boost.Context について調べた http://d.hatena.ne.jp/melpon/20111213/1323704464
3+
4+
Continuation with Boost.Context http://www.slideshare.net/faithandbrave/continuation-with-boostcontext
5+
6+
Boost.Context 非同期?理を逐次的にする http://d.hatena.ne.jp/faith_and_brave/20120329/1333008572
7+
8+
boost.contextを使ってみました http://d1z.cocolog-nifty.com/blog/2012/02/boostcontext-ac.html
9+
10+
Boost.Contextでファイバ?ライブラリを??してみた http://yohhoy.hatenablog.jp/entry/2012/04/10/003735
11+
12+
13+
Coroutine , fiber 実行コンテキストの抽象化ライブラリ達
14+
http://www.flast.jp/article/boost-21-sapporo/index.html
15+
http://www.flast.jp/article/boost-21-sapporo/execution.html
16+
17+
Boost.Coroutineのローカル変数の寿命 http://d.hatena.ne.jp/y_mazun/20130205/1360077844
18+
19+
Boost.Coroutine でフィボナッチ http://d.hatena.ne.jp/osyo-manga/20130209/1360412742
20+
21+
Boost.Coroutine http://d.hatena.ne.jp/joynote/20131118/1384779314
22+
23+
C++ のコルーチン boost::coroutines を使ってみる http://qiita.com/kobake@github/items/506b5ff128dc1372cd1d
24+
25+
C++14 & boost::{coroutines|signals2} -> yieldable task system http://qiita.com/usagi/items/6dad042e20ef1fe9f91c
26+
27+
Visual C++ CoroutineとBoost Coroutine http://sayurin.blogspot.kr/2016/07/visual-c-coroutineboost-coroutine_9.html
28+

dll.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Boost.DLL
2+
[공식 문서(1.73)](https://www.boost.org/doc/libs/1_73_0/libs/dll/ )
3+
4+
5+
6+
## 플러그인 시스템을 Boost.DLL로 간단하게 구현하기
7+
[출처](https://qiita.com/usagi/items/0722550dc5433bd07139 )
8+
9+
### 준비할 것
10+
1. plugin_type.hxx : 이 글에서 설명할 플러그인의 기본 타입 소스. 애플리케이션과 플러그인 각각에서 include 해서 사용한다.
11+
2. plugin_a.cxx : plugin_type을 기본으로 구현되는 구체적인 플러그인 소스.
12+
3. app.cxx : 플러그인을 사용하고 싶은 애플리케이션의 소스.
13+
14+
<br>
15+
16+
plugin_type.hxx:
17+
```
18+
#pragma once
19+
20+
#include <string>
21+
22+
namespace usagi::example::boost_dll
23+
{
24+
class plugin_type
25+
{
26+
public:
27+
virtual auto get_name() const -> std::string;
28+
virtual auto operator()( const int a, const int b ) const -> int;
29+
virtual ~plugin_type() { }
30+
};
31+
}
32+
```
33+
34+
35+
plugin_a.cxx:
36+
```
37+
#include "plugin_type.hxx"
38+
#include <boost/config.hpp>
39+
40+
namespace usagi::example::boost_dll
41+
{
42+
class plugin_a : public plugin_type
43+
{
44+
public:
45+
auto get_name() const -> std::string override { return "adder"; }
46+
auto operator()( const int a, const int b ) const -> int override { return a + b; };
47+
};
48+
49+
extern "C" BOOST_SYMBOL_EXPORT plugin_a plugin;
50+
plugin_a plugin;
51+
}
52+
```
53+
54+
55+
app.cxx:
56+
```
57+
#include "plugin_type.hxx"
58+
#include <boost/dll/import.hpp>
59+
#include <iostream>
60+
61+
auto main() -> int
62+
{
63+
using namespace std;
64+
using namespace usagi::example::boost_dll;
65+
// ↓ op는 boost::shared_ptr< plugin_type > 타입으로 주어진다.
66+
// (std::shared_ptr 로 변환하고 싶은 경우는 http://qiita.com/usagi/items/3563ddb01e4eb342485e를 참조한다.
67+
auto op =
68+
boost::dll::import< plugin_type >
69+
// ↓ 로드할 플러그인의 패스
70+
( boost::filesystem::path( "plugin_a" )
71+
// ↓ import 할 대상의 플러그인으로 import 되고 있는 심볼
72+
, "plugin"
73+
// ↓ 이것을 붙여 두면 .so 나 .dll 을 패스에 자동으로 추가해 주므로 편리하다
74+
, boost::dll::load_mode::append_decorations
75+
);
76+
77+
cout << op->get_name() << " " << (*op)( 1, 2 ) << endl;
78+
}
79+
```
80+
81+
82+
### 응용: poker 플레이어 AI를 플러그인 화하여 놀수 있도록 한 예
83+
[GitHub - usagi/poker](https://github.com/usagi/poker)
84+
85+
poker/source/player_b.cxx:
86+
```
87+
#include "player_type.hxx"
88+
89+
#include <boost/config.hpp>
90+
91+
#include <algorithm>
92+
93+
namespace usagi::poker
94+
{
95+
using namespace std;
96+
97+
class player_b: public player_type
98+
{
99+
auto get_name() -> std::string override
100+
{
101+
return "Player-B/Heart-man";
102+
}
103+
104+
auto pay_ante( const size_t my_chips, const size_t minimum, const size_t maximum ) -> size_t override
105+
{
106+
if ( my_chips < 100 )
107+
return 1;
108+
else if ( my_chips < 1000 )
109+
return ( minimum + maximum ) / 2;
110+
return maximum;
111+
}
112+
113+
auto discard_cards( const cards_type drew_cards ) -> cards_type override
114+
{
115+
// 러브 하트 알고리즘
116+
cards_type discards;
117+
118+
copy_if
119+
( drew_cards.cbegin()
120+
, drew_cards.cend()
121+
, back_inserter( discards )
122+
, []( const auto& card ) { return card.get_suit() != suit_type::heart; }
123+
);
124+
125+
return discards;
126+
}
127+
};
128+
129+
extern "C" BOOST_SYMBOL_EXPORT player_b player;
130+
player_b player;
131+
}
132+
```
133+

in_place.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# boost::in_place
2+
3+
[출처](https://nekko1119.hatenablog.com/entry/20121122/1353577143 )
4+
`boost::in_place`를 사용하면 확복한 메모리에 오브젝트를 뒤에서 만들 수 있다.
5+
copy 불가한 오브젝트도 재 구축으로 재 대입하는 행동을 한다.
6+
7+
trivial destructor를 가진 클래스는 소멸하지 않고 재 구축 할 수 있다.
8+
9+
```
10+
#include <iostream>
11+
#include <string>
12+
#include <sstream>
13+
#include <boost/utility/in_place_factory.hpp>
14+
15+
template<class T>
16+
class hoge
17+
{
18+
public:
19+
20+
//T 타입 분의 메모리를 확보한다
21+
hoge() : buffer_(reinterpret_cast<T*>(new char[sizeof(T)]))
22+
{
23+
}
24+
25+
//메모리 해제
26+
~hoge()
27+
{
28+
delete buffer_;
29+
}
30+
31+
//확보한 메모리에 오브젝트를 확보한다
32+
template<class InPlace>
33+
void construct(const InPlace& p)
34+
{
35+
p.template apply<T>(buffer_);
36+
}
37+
38+
//오브젝트 파괴
39+
void destroy()
40+
{
41+
buffer_->~T();
42+
}
43+
44+
std::string to_string() const
45+
{
46+
return buffer_->to_string();
47+
}
48+
49+
private:
50+
T* buffer_;
51+
};
52+
53+
class point
54+
{
55+
public:
56+
point(int x, int y) : x_(x), y_(y)
57+
{
58+
}
59+
60+
std::string to_string() const
61+
{
62+
std::ostringstream oss;
63+
oss << "(" << x_ << ", " << y_ << ")";
64+
return oss.str();
65+
}
66+
67+
private:
68+
int x_;
69+
int y_;
70+
};
71+
72+
int main()
73+
{
74+
hoge<point> a;// 메모리 확보
75+
a.construct(boost::in_place(100, 200));//오브젝트 구축
76+
std::cout << a.to_string() << std::endl;
77+
78+
//point 타입은 trivial destructor 이므로 소멸하지 않고 재 구축 할 수 있다
79+
80+
a.construct(boost::in_place(300, 400));//재 구축
81+
std::cout << a.to_string() << std::endl;
82+
83+
return 0;
84+
}
85+
```
86+
87+
실행 결과:
88+
<pre>
89+
(100, 200)
90+
(300, 400)
91+
</pre>
92+

0 commit comments

Comments
 (0)