├── .gitignore ├── 000_working_list.md ├── CRC.md ├── Context.md ├── Geometry.md ├── HOF.md ├── LICENSE ├── Log.md ├── OverloadedFunction.md ├── PP.md ├── README.md ├── Redis.md ├── SCOPE_EXIT.md ├── TTI.md ├── UUID.md ├── algorithm.md ├── boost_container ├── allocator.md ├── codes │ ├── circular_buffer_01 │ │ ├── circular_buffer_01.cpp │ │ ├── circular_buffer_01.vcxproj │ │ └── circular_buffer_01.vcxproj.filters │ ├── circular_buffer_02 │ │ ├── circular_buffer_02.cpp │ │ ├── circular_buffer_02.vcxproj │ │ └── circular_buffer_02.vcxproj.filters │ ├── circular_buffer_03 │ │ ├── circular_buffer_03.cpp │ │ ├── circular_buffer_03.vcxproj │ │ └── circular_buffer_03.vcxproj.filters │ ├── circular_buffer_04 │ │ ├── circular_buffer_04.cpp │ │ ├── circular_buffer_04.vcxproj │ │ └── circular_buffer_04.vcxproj.filters │ ├── circular_buffer_05 │ │ ├── circular_buffer_05.cpp │ │ ├── circular_buffer_05.vcxproj │ │ └── circular_buffer_05.vcxproj.filters │ ├── flat_map_01 │ │ ├── flat_tree_01.cpp │ │ ├── flat_tree_01.vcxproj │ │ └── flat_tree_01.vcxproj.filters │ ├── multi_index_01 │ │ ├── multi_index_01.cpp │ │ ├── multi_index_01.vcxproj │ │ └── multi_index_01.vcxproj.filters │ ├── multi_index_02 │ │ ├── multi_index_02.cpp │ │ ├── multi_index_02.vcxproj │ │ └── multi_index_02.vcxproj.filters │ ├── multi_index_03 │ │ ├── multi_index_03.cpp │ │ ├── multi_index_03.vcxproj │ │ └── multi_index_03.vcxproj.filters │ ├── multi_index_04 │ │ ├── multi_index_04.cpp │ │ ├── multi_index_04.vcxproj │ │ └── multi_index_04.vcxproj.filters │ ├── multi_index_05 │ │ ├── multi_index_05.cpp │ │ ├── multi_index_05.vcxproj │ │ └── multi_index_05.vcxproj.filters │ ├── multi_index_06 │ │ ├── multi_index_06.cpp │ │ ├── multi_index_06.vcxproj │ │ └── multi_index_06.vcxproj.filters │ ├── multi_index_07 │ │ ├── multi_index_07.cpp │ │ ├── multi_index_07.vcxproj │ │ └── multi_index_07.vcxproj.filters │ ├── multi_index_08 │ │ ├── multi_index_08.cpp │ │ ├── multi_index_08.vcxproj │ │ └── multi_index_08.vcxproj.filters │ ├── multi_index_09 │ │ ├── multi_index_09.cpp │ │ ├── multi_index_09.vcxproj │ │ └── multi_index_09.vcxproj.filters │ ├── stable_vector_01 │ │ ├── stable_vector_01.cpp │ │ ├── stable_vector_01.vcxproj │ │ └── stable_vector_01.vcxproj.filters │ ├── stable_vector_02 │ │ ├── stable_vector_02.cpp │ │ ├── stable_vector_02.vcxproj │ │ └── stable_vector_02.vcxproj.filters │ ├── static_vector_01 │ │ ├── static_vector_01.cpp │ │ ├── static_vector_01.vcxproj │ │ └── static_vector_01.vcxproj.filters │ └── static_vector_02 │ │ ├── static_vector_02.cpp │ │ ├── static_vector_02.vcxproj │ │ └── static_vector_02.vcxproj.filters ├── flat_map-set.md ├── heap.md ├── index.md ├── resource │ ├── 001.PNG │ ├── 002.PNG │ ├── 003.PNG │ ├── 004.PNG │ ├── 005.PNG │ ├── 006.PNG │ ├── 007.PNG │ ├── 008.PNG │ ├── 009.PNG │ ├── 010.PNG │ ├── 011.PNG │ ├── 012.PNG │ ├── 013.PNG │ └── 014.PNG ├── stable_vector.md └── static_vector.md ├── build.md ├── circular_buffer.md ├── cobalt.md ├── date_time.md ├── dll.md ├── graph.md ├── in_place.md ├── msm.md ├── multi_index.md ├── numeric-interval.md ├── pool.md ├── predef.md ├── program_options.md ├── redis ├── main.cpp ├── redis.sln ├── redis.vcxproj └── redis.vcxproj.filters ├── reference_wrapper.md ├── resource ├── 072012_1617_boost1.png ├── 072012_1617_boost2.png ├── 072012_1617_boost3.png ├── 072012_1617_boost4.png ├── 20120718163035.png ├── 20120718163852.png ├── AsynchronousUDPClient_future.zip ├── ChattingTCPServer_spawn.zip ├── Eclipse_boost-1.PNG ├── Eclipse_boost-2.PNG ├── Eclipse_boost-3.PNG ├── Eclipse_boost-4.PNG ├── Eclipse_boost-5.PNG ├── Eclipse_boost-6.PNG ├── HttpClient.zip ├── VC10_setting-1.png ├── VC10_setting-2.png ├── VC10_setting-3.png ├── asio_cpp11_future.png ├── asio_cpp11_packaged_task_01.png ├── asio_cpp11_packaged_task_02.png ├── asio_spawn_01.png ├── asio_spawn_02.png ├── boost_crc-001.png ├── boost_crc-002.png ├── boost_crc_01.zip ├── io_service_post_packaged_task.zip ├── mono_boost-1.PNG ├── mono_boost-2.PNG ├── mono_boost-3.PNG ├── mono_boost-4.PNG ├── mono_boost-5.PNG ├── mono_boost-6.PNG ├── ubuntu_boost_build-1.PNG ├── ubuntu_boost_build-2.PNG ├── ubuntu_boost_build-3.PNG ├── ubuntu_boost_build-4.PNG ├── ubuntu_boost_build-5.PNG ├── ubuntu_boost_build-6.PNG └── vc_lib_down.png ├── signals2.md ├── string.md ├── timer.md └── variant.md /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studo 2015 cache/options directory 26 | .vs/ 27 | 28 | # MSTest test Results 29 | [Tt]est[Rr]esult*/ 30 | [Bb]uild[Ll]og.* 31 | 32 | # NUNIT 33 | *.VisualState.xml 34 | TestResult.xml 35 | 36 | # Build Results of an ATL Project 37 | [Dd]ebugPS/ 38 | [Rr]eleasePS/ 39 | dlldata.c 40 | 41 | *_i.c 42 | *_p.c 43 | *_i.h 44 | *.ilk 45 | *.meta 46 | *.obj 47 | *.pch 48 | *.pdb 49 | *.pgc 50 | *.pgd 51 | *.rsp 52 | *.sbr 53 | *.tlb 54 | *.tli 55 | *.tlh 56 | *.tmp 57 | *.tmp_proj 58 | *.log 59 | *.vspscc 60 | *.vssscc 61 | .builds 62 | *.pidb 63 | *.svclog 64 | *.scc 65 | 66 | # Chutzpah Test files 67 | _Chutzpah* 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | *.cachefile 76 | 77 | # Visual Studio profiler 78 | *.psess 79 | *.vsp 80 | *.vspx 81 | 82 | # TFS 2012 Local Workspace 83 | $tf/ 84 | 85 | # Guidance Automation Toolkit 86 | *.gpState 87 | 88 | # ReSharper is a .NET coding add-in 89 | _ReSharper*/ 90 | *.[Rr]e[Ss]harper 91 | *.DotSettings.user 92 | 93 | # JustCode is a .NET coding addin-in 94 | .JustCode 95 | 96 | # TeamCity is a build add-in 97 | _TeamCity* 98 | 99 | # DotCover is a Code Coverage Tool 100 | *.dotCover 101 | 102 | # NCrunch 103 | _NCrunch_* 104 | .*crunch*.local.xml 105 | 106 | # MightyMoose 107 | *.mm.* 108 | AutoTest.Net/ 109 | 110 | # Web workbench (sass) 111 | .sass-cache/ 112 | 113 | # Installshield output folder 114 | [Ee]xpress/ 115 | 116 | # DocProject is a documentation generator add-in 117 | DocProject/buildhelp/ 118 | DocProject/Help/*.HxT 119 | DocProject/Help/*.HxC 120 | DocProject/Help/*.hhc 121 | DocProject/Help/*.hhk 122 | DocProject/Help/*.hhp 123 | DocProject/Help/Html2 124 | DocProject/Help/html 125 | 126 | # Click-Once directory 127 | publish/ 128 | 129 | # Publish Web Output 130 | *.[Pp]ublish.xml 131 | *.azurePubxml 132 | # TODO: Comment the next line if you want to checkin your web deploy settings 133 | # but database connection strings (with potential passwords) will be unencrypted 134 | *.pubxml 135 | *.publishproj 136 | 137 | # NuGet Packages 138 | *.nupkg 139 | # The packages folder can be ignored because of Package Restore 140 | **/packages/* 141 | # except build/, which is used as an MSBuild target. 142 | !**/packages/build/ 143 | # Uncomment if necessary however generally it will be regenerated when needed 144 | #!**/packages/repositories.config 145 | 146 | # Windows Azure Build Output 147 | csx/ 148 | *.build.csdef 149 | 150 | # Windows Store app package directory 151 | AppPackages/ 152 | 153 | # Others 154 | *.[Cc]ache 155 | ClientBin/ 156 | [Ss]tyle[Cc]op.* 157 | ~$* 158 | *~ 159 | *.dbmdl 160 | *.dbproj.schemaview 161 | *.pfx 162 | *.publishsettings 163 | node_modules/ 164 | bower_components/ 165 | 166 | # RIA/Silverlight projects 167 | Generated_Code/ 168 | 169 | # Backup & report files from converting an old project file 170 | # to a newer Visual Studio version. Backup files are not needed, 171 | # because we have git ;-) 172 | _UpgradeReport_Files/ 173 | Backup*/ 174 | UpgradeLog*.XML 175 | UpgradeLog*.htm 176 | 177 | # SQL Server files 178 | *.mdf 179 | *.ldf 180 | 181 | # Business Intelligence projects 182 | *.rdl.data 183 | *.bim.layout 184 | *.bim_*.settings 185 | 186 | # Microsoft Fakes 187 | FakesAssemblies/ 188 | 189 | # Node.js Tools for Visual Studio 190 | .ntvs_analysis.dat 191 | 192 | # Visual Studio 6 build log 193 | *.plg 194 | 195 | # Visual Studio 6 workspace options file 196 | *.opt 197 | -------------------------------------------------------------------------------- /000_working_list.md: -------------------------------------------------------------------------------- 1 | # 정리 작업 리스트 2 | https://www.boost.org/ 3 | [(일어)boost 라이브러리 정보](http://boostjp.github.io/ ) 4 | 5 | - Boost.JSON https://www.boost.org/doc/libs/1_84_0/libs/json/doc/html/index.html 6 | - Boost.MySQL https://www.boost.org/doc/libs/1_84_0/libs/mysql/doc/html/index.html 7 | - Boost.Beast https://www.boost.org/doc/libs/1_84_0/libs/beast/doc/html/index.html 8 | - https://www.boost.org/doc/libs/1_84_0/doc/html/lockfree.html 9 | - lockfree::queue https://boostjp.github.io/tips/lockfree-queue.html 10 | - lockfree::stack https://boostjp.github.io/tips/lockfree-stack.html 11 | - Boost.ContainerHash https://www.boost.org/doc/libs/1_84_0/libs/container_hash/doc/html/hash.html 12 | - https://www.boost.org/doc/libs/1_72_0/doc/html/atomic/usage_examples.html 13 | - https://www.boost.org/doc/libs/1_72_0/doc/html/container.html 14 | - https://www.boost.org/doc/libs/1_72_0/doc/html/hash.html 15 | - https://www.boost.org/doc/libs/1_72_0/doc/html/boost_dll.html 16 | - https://www.boost.org/doc/libs/1_72_0/libs/parameter/doc/html/index.html 17 | - https://www.boost.org/doc/libs/1_84_0/doc/html/stacktrace.html 18 | - https://www.boost.org/doc/libs/1_72_0/libs/vmd/doc/html/index.html 19 | - https://www.boost.org/doc/libs/1_72_0/doc/html/yap.html 20 | 21 | 22 | ## TypeErasure 23 | Boost.TypeErasure を使ってみる http://d.hatena.ne.jp/osyo-manga/20121202/1354456126 24 | Boost.TypeErasureのドキュメントを翻訳してみた http://d.hatena.ne.jp/gununu/20130705/1372983790 25 | 26 | 27 | 28 | ## mpl 29 | Try to use boost.mpl http://www.slideshare.net/Suikaba/try-to-use-boostmpl 30 | '11年代のMPL https://kikairoya.hatenablog.com/entry/20111206/1323183937 31 | 32 | 33 | 34 | ## wave 35 | http://www.ruche-home.net/program/boost/wave 36 | 37 | 38 | 39 | ## Hana 40 | Boost.Hana の紹介! https://qiita.com/alphya/items/94dcfc4dd08445f9c62b 41 | Use the official Boost.Hana with MSVC 2017 Update 8 compiler https://blogs.msdn.microsoft.com/vcblog/2018/08/30/use-the-official-boost-hana-with-msvc-2017-update-8-compiler/ 42 | 43 | 44 | 45 | ## Xpressive 46 | Boost.Xpressive で HTML タグの中身とタグ名を取得する http://d.hatena.ne.jp/osyo-manga/20120516/1337152762 47 | 48 | 일본어 문서 http://alpha.sourceforge.jp/devel/boost.xpressive_ja_1_45_0.pdf 49 | 50 | 51 | 52 | ## Spirit 53 | 한글 번역 문서 http://jacking75.cafe24.com/Boost/Spirit/index.htm 54 | 최신 버전 문서 http://www.boost.org/doc/libs/1_42_0/libs/spirit/doc/html/index.html 55 | 버전 2에 대한 간단한 설명 http://www-ise2.ist.osaka-u.ac.jp/~kimura/boost/?Spirit 56 | 57 | < 예제 > 58 | http://www.kmonos.net/alang/boost/classes/spirit.html 59 | http://www.fides.dti.ne.jp/~oka-t/cpplab-boost-spirit.html 60 | http://tamachan.club.kyutech.ac.jp/~gridbug/spirit/ 61 | http://www.kanetaka.net/4dapi/wiki4d.dll/4dcgi/wiki.cgi?Boost::Spirit= 62 | http://d.hatena.ne.jp/amachang/20081002/1222977482 63 | JSON 파서 http://babei.sblo.jp/article/24971565.html 64 | 65 | 66 | 67 | # Proto 68 | boost 라이브러리의 Spirit, Phoenix, MSM, Xpressive가 Proto 사용 69 | 70 | 시작 http://d.hatena.ne.jp/faith_and_brave/20090501/1241167261 71 | Boost.Proto http://www.slideshare.net/fjnl/boost4-boostproto 72 | http://0x35.tumblr.com/post/16706887475/boost-proto 73 | 74 | 75 | 76 | ## 직렬화 77 | Boost 직렬화에서 사용하고 있는 싱글톤 http://d.hatena.ne.jp/redboltz/20100226/1267140671 78 | 79 | 80 | 81 | ## Fusion 82 | Boost.Fusionでreplicate http://d.hatena.ne.jp/faith_and_brave/20120720/1342768623 83 | Type Driven Wire Protocols with Boost Fusion http://rodgert.github.io/2014/09/09/type-driven-wire-protocols-with-boost-fusion-pt1/ 84 | 85 | 86 | ## QVM 87 | 행열 계산 라이브러리. 88 | 89 | Boost QVM(Quaternions, Vectors, Matrices)に触ってみた http://qiita.com/yacohana/items/c249ade084c41e68da29 90 | Boost.QVM入門 https://qiita.com/agate-pris/items/3e0bb170e5c6356df108 91 | 92 | 93 | # Boost.Context 94 | Boost.Context について調べた http://d.hatena.ne.jp/melpon/20111213/1323704464 95 | Continuation with Boost.Context http://www.slideshare.net/faithandbrave/continuation-with-boostcontext 96 | Boost.Context 非同期?理を逐次的にする http://d.hatena.ne.jp/faith_and_brave/20120329/1333008572 97 | boost.contextを使ってみました http://d1z.cocolog-nifty.com/blog/2012/02/boostcontext-ac.html 98 | Boost.Contextでファイバ?ライブラリを??してみた http://yohhoy.hatenablog.jp/entry/2012/04/10/003735 99 | Coroutine , fiber 実行コンテキストの抽象化ライブラリ達 100 | http://www.flast.jp/article/boost-21-sapporo/index.html 101 | http://www.flast.jp/article/boost-21-sapporo/execution.html 102 | Boost.Coroutineのローカル変数の寿命 http://d.hatena.ne.jp/y_mazun/20130205/1360077844 103 | Boost.Coroutine でフィボナッチ http://d.hatena.ne.jp/osyo-manga/20130209/1360412742 104 | Boost.Coroutine http://d.hatena.ne.jp/joynote/20131118/1384779314 105 | C++ のコルーチン boost::coroutines を使ってみる http://qiita.com/kobake@github/items/506b5ff128dc1372cd1d 106 | C++14 & boost::{coroutines|signals2} -> yieldable task system http://qiita.com/usagi/items/6dad042e20ef1fe9f91c 107 | Visual C++ CoroutineとBoost Coroutine http://sayurin.blogspot.kr/2016/07/visual-c-coroutineboost-coroutine_9.html 108 | 109 | 110 | # boost::graph 111 | boost::graphのお勉強 http://qiita.com/kktk-KO/items/6c53e1c550cae441c969 112 | boostのグラフ別,動作の違い http://folioscope.hatenablog.jp/entry/2012/10/31/224238 113 | Boost.GraphでJR全線乗り尽くしプランを立てる - プログラミング生放送 http://www.slideshare.net/maraigue/chinese-postman 114 | http://boost.cppll.jp/HEAD/libs/graph/doc/graph_theory_review.html 115 | http://d.hatena.ne.jp/faith_and_brave/20100413/1271129607 116 | http://d.hatena.ne.jp/faith_and_brave/20100415/1271315024 117 | http://d.hatena.ne.jp/faith_and_brave/20100416/1271388752 118 | Boost.Graph 到達可能かどうかをチェックする http://d.hatena.ne.jp/faith_and_brave/20111011/1318317668 119 | Boost.Graph 最短?路の長さ(weight)を計算する http://d.hatena.ne.jp/faith_and_brave/20111012/1318407981 120 | Boost.Graph filtered_graph http://d.hatena.ne.jp/faith_and_brave/20111014/1318572553 121 | Boost.Graph is_reachableAdd Star http://d.hatena.ne.jp/faith_and_brave/20111017/1318837488 122 | Boost.Graph is_adjacent http://d.hatena.ne.jp/faith_and_brave/20111018/1318915464 123 | Boost.Graph vectorを有向グラフとして使用する http://d.hatena.ne.jp/faith_and_brave/20111019/1319002566 124 | Boost.Graph 頂点と辺の数を取得 http://d.hatena.ne.jp/faith_and_brave/20111031/1320039384 125 | Boost.Graph PredecessorMap http://d.hatena.ne.jp/faith_and_brave/20111101/1320125923 126 | Boost.Graph DistanceMap http://d.hatena.ne.jp/faith_and_brave/20111102/1320211726 127 | Boost.Graph 最短経路を計算する過程を取得 http://d.hatena.ne.jp/faith_and_brave/20111115/1321338504 128 | Boost.Graph 2つのグラフが同型かを調べる http://d.hatena.ne.jp/faith_and_brave/20120612/1339489283 129 | Boost.Graph トポロジカルソート http://d.hatena.ne.jp/faith_and_brave/20120613/1339577486 130 | グラフ理論 Welsh-Powellの頂点彩色アルゴリズムを実装してみた http://d.hatena.ne.jp/devm33/20120616/1339811432 131 | Boost.Graph Bundleプロパティ http://d.hatena.ne.jp/faith_and_brave/20120619/1340093038 132 | Boost.Graph 最短?純路 http://d.hatena.ne.jp/faith_and_brave/20120626/1340689362 133 | Boost.Graph 最小全域木を作る http://d.hatena.ne.jp/faith_and_brave/20120627/1340783683 134 | Boost.Graph 一筆書き http://d.hatena.ne.jp/faith_and_brave/20120628/1340866757 135 | Boost.Graph 複?ソ?スの幅優先探索 http://d.hatena.ne.jp/faith_and_brave/20121120/1353405062 136 | Boost.Graph スモールワールドを作る http://d.hatena.ne.jp/faith_and_brave/20121207/1354866489 137 | Boost.Graph 全頂点間最短距離を求め http://d.hatena.ne.jp/faith_and_brave/20121212/1355295002 138 | astar_shortest_path.cpp https://gist.github.com/faithandbrave/7331277 139 | Boost.Graphでの最短経路探索 http://goyoki.hatenablog.com/entry/2014/03/02/023758 140 | Boost.Graph Graphvizの情報をユーザー定義型に読み込む http://faithandbrave.hateblo.jp/entry/2015/04/13/231836 141 | 最短経路探索 (Boost Graph Library 利用でダイクストラ法) https://qiita.com/kkdd/items/73fdc783799a71f19d15 142 | 143 | 144 | # Boost::msm 145 | Boost.Msm 사용 방법 http://www.slideshare.net/redboltz/boost-sapporomsm-pre 146 | https://sites.google.com/site/boostjp/tips/finite_state_machine 147 | http://d.hatena.ne.jp/osyo-manga/20100917/1284716191 148 | http://d.hatena.ne.jp/kura-replace/20110514/1305385110 149 | http://d.hatena.ne.jp/redboltz/20110625/1308997694 150 | http://d.hatena.ne.jp/redboltz/20110626/1309046959 151 | http://d.hatena.ne.jp/redboltz/20110626/1309074006 152 | if/else分岐 http://d.hatena.ne.jp/redboltz/20110722/1311312541 153 | Boost.Msmがサポ?トしないUML表記とその??法 http://d.hatena.ne.jp/redboltz/20110722/1311297996 154 | http://d.hatena.ne.jp/redboltz/20110726/1311682730 155 | 開始疑似?態と?行?態 http://d.hatena.ne.jp/redboltz/20110803/1312336449 156 | entry point疑似?態の?? http://d.hatena.ne.jp/redboltz/20110803/1312359024 157 | 状態マシンの内部で別のイベントを発生させる http://d.hatena.ne.jp/redboltz/20110813/1313244419 158 | イベントの延期(defer) http://d.hatena.ne.jp/redboltz/20110815/1313388757 159 | 遷移テ?ブルの評?順序を上から下にする http://d.hatena.ne.jp/redboltz/20110818/1313655344 160 | entry pseudo stateのリージョンIDの省略 http://d.hatena.ne.jp/redboltz/20120306/1331030665 161 | entry point疑似?態の??の制約とその??策 http://d.hatena.ne.jp/redboltz/20120603/1338706853 162 | -------------------------------------------------------------------------------- /CRC.md: -------------------------------------------------------------------------------- 1 | ### 개요 2 | 데이터 전송 등이 올바르게 되었는지를 검사하기 위한 방법으로 CRC(Cyclic Redundancy Check) 번호라고 부르는 값을 폭 넓게 사용하고 있다. 3 | Boost.Crc 라이브러리는 비트 열에서 CRC 값을 계산하기 위한 라이브러리이다. 4 | 5 | 6 | 7 | 8 | 9 | [예제코드](resource\boost_crc_01.zip) 10 | -------------------------------------------------------------------------------- /Context.md: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /HOF.md: -------------------------------------------------------------------------------- 1 | # Boost.HOF 2 | Boost 1.67.0에서 [Boost.HOF](https://github.com/boostorg/hof ) 라는 라이브러리가 추가 되었다. 3 | HOF은 Higher Order Functions( 고차 함수 )의 약자로, 함수 또는 함수 객체 유틸리티를 제공하는 라이브러리이다. 4 | header-only로 C++11 이상의 환경에서 사용할 수 있다. 5 | 6 | 3개의 구성 요소 가 포함되어 있습니다. 7 | - Function Adaptors and Decorators: 기존의 기능을 강화하는 어댑터와 데코레이터 8 | - Functions : 특정 목적을 위한 함수 9 | - Utilities : 함수 정의 및 사용 시 사용할 범용 유틸리티 10 | 11 | 12 | 13 | ## Function Adapters and Decorators 14 | 15 | ### Funcition Adaptors 16 | Function Adapters는 함수를 받고, 이 함수를 바탕으로 새로운 함수를 반환한다. 17 | 18 | #### lazy 19 | lazy는 std::bind 처럼 사용할 수있는 어댑터이다. 20 | std :: bind와 다른 것은 constexpr에서도 이용할 수 있다는 점이다. 21 | 샘플은 add의 제 2인자를 3으로 속박한 함수를 반환한다. 22 | ``` 23 | #include 24 | namespace hof = boost::hof; 25 | 26 | constexpr int add(int a, int b) { 27 | return a + b; 28 | } 29 | 30 | int main() { 31 | constexpr auto addThree = hof::lazy(add)(hof::_1, 3); 32 | static_assert(addThree(5) == 8); 33 | } 34 | ``` 35 | 36 | 37 | #### pipable 38 | pipable는 f(x, args...) 같은 함수를 x | f(args...) 형태로 부를 수 있도록한다. 39 | C++ 에서 `operator.` 는 오버로드 할 수 없지만 free 함수를 멤버 함수처럼 하는 이미지이다. 40 | (이미지 x(f)-> x.f()) 메소드 체인을 깨끗이한다. 41 | ( g(h(f(x)) ) 같은 호출이 x | f() | h() | g() 같이 변형 할 수 있다) 샘플은 added 좌변이 add의 제 1인자이다. 42 | ``` 43 | #include 44 | namespace hof = boost::hof; 45 | 46 | constexpr int add(int a, int b) { 47 | return a + b; 48 | } 49 | 50 | int main() { 51 | constexpr auto added = hof::pipable(add); 52 | constexpr auto result = 3 | added(5) | added(7); 53 | static_assert(result == 15); 54 | } 55 | ``` 56 | 57 | 58 | 59 | #### flow 60 | flow는 여러 함수를 받고, 이 함수를 차례로 호출하는 함수를 반환한다. 61 | 하나 전의 함수의 반환 값이 다음 함수의 인수이다. 62 | 사용법에 따라서는 pipable와 비슷할 수 있다. 63 | 샘플은 인수로 전달된 문자열을 html 태그로 둘러싸고 있다. 64 | ``` 65 | #include 66 | #include 67 | #include 68 | namespace hof = boost::hof; 69 | 70 | std::string addpre(std::string const& str) { 71 | return "
" + str + "
"; 72 | } 73 | 74 | std::string adddiv(std::string const& str) { 75 | return "
" + str + "
"; 76 | } 77 | 78 | int main() { 79 | auto wrap = hof::flow(addpre, adddiv, adddiv); 80 | std::cout << wrap("aaa") << std::endl; 81 | } 82 | ``` 83 | 84 | 출력 85 |
 86 | 
aaa
87 |
88 | 89 | 90 | 91 | #### infix 92 | infix는 2개의 인수를 취하는 함수를 연결(중간 기법 모두)에 쓸 수 있도록 한다. 93 | a + b의 + 같은 이항 연산자의 연산자 위치 이미지이다. 94 | 구체적으로는 `f(x, y)` 을 `x y` 형식으로 부를 수 있도록 한다. 95 | 샘플은 std::equal_to을 중간 기법으로 부를 수 있도록 한다. 96 | ``` 97 | #include 98 | #include 99 | namespace hof = boost::hof; 100 | 101 | int main() { 102 | constexpr auto equals = hof::infix(std::equal_to<>{}); 103 | constexpr auto a = 42; 104 | constexpr auto b = 42; 105 | static_assert(a b); 106 | } 107 | ``` 108 | 109 | 110 | 111 | #### proj 112 | proj는 proj의 제 2인자로 전달된 함수를 호출 할 때 각 인수에 첫 번째 인수로 전달된 함수를 호출하고 나서 전달한다. 113 | `proj(p, f)(1, 2, 3) == f(p(1), p(2), p(3))` 같은 이미지이다. 114 | ``` 115 | #include 116 | #include 117 | namespace hof = boost::hof; 118 | 119 | int twice(int x) { 120 | return x * 2; 121 | } 122 | 123 | void print(int x, int y, int z) { 124 | std::cout << x << " " << y << " " << z; 125 | } 126 | 127 | int main() { 128 | constexpr auto twiced_print = hof::proj(twice, print); 129 | twiced_print(5, 7, 11); 130 | } 131 | ``` 132 | 133 | 출력 134 |
135 | 10 14 22
136 | 
137 | 138 | 139 | 140 | ### Decorators 141 | Decoratorssms 함수를 받고, Function Adapter를 반환하는 함수이다. 142 | 143 | #### repeat 144 | repeat는 지정된 횟수만큼 함수 호출을 중첩한다. 145 | 샘플은 초기 값 1에서 2배하는 함수를 10번 호출한다. 146 | ``` 147 | #include 148 | namespace hof = boost::hof; 149 | 150 | constexpr int twice(int x) { 151 | return x * 2; 152 | } 153 | 154 | int main() { 155 | constexpr auto pow_10 = hof::repeat(10)(twice); 156 | static_assert(pow_10(1) == 1024); 157 | } 158 | ``` 159 | 160 | 161 | 162 | #### if_ 163 | if는 제 1 인수에 조건 메타 함수를 가지고, 이것이 true_type인 경우 제 2인수로 전달된 함수를 호출하는 함수를 반환한다. 164 | false_type의 경우 함수 호출하면 컴파일 오류가 되도록한다. 165 | 샘플의 주석을 제거하면 컴파일 오류가 발생한다. true의 경우는 twice가 그대로 호출된다. 166 | ``` 167 | #include 168 | #include 169 | namespace hof = boost::hof; 170 | 171 | constexpr int twice(int x) { 172 | return x * 2; 173 | } 174 | 175 | int main() { 176 | hof::if_(std::bool_constant{})(twice)(1); 177 | // hof::if_(std::bool_constant{})(twice)(1); 178 | } 179 | ``` 180 | 181 | 182 | 183 | ## Functions and Utilities 184 | 기타 유용한 기능을 소개한다 185 | 186 | ### always 187 | always는 인수로 취한 값을 반환하는 함수를 반환한다. 188 | 이 함수는 임의의 인수를 취할 수 있지만 반환 값은 고정이다. 샘플은 항상 1을 반환하는 함수를 작성하고 있다. 189 | ``` 190 | #include 191 | namespace hof = boost::hof; 192 | 193 | int main() { 194 | constexpr auto one = hof::always(1); 195 | static_assert(one() == 1); 196 | static_assert(one(1, 3.14, "hello") == 1); 197 | } 198 | ``` 199 | 200 | 201 | 202 | ### identity 203 | identity는 인수로 전달된 값을 그대로 반환하는 함수이다. 204 | ``` 205 | #include 206 | namespace hof = boost::hof; 207 | 208 | int main() { 209 | static_assert(hof::identity(42) == 42); 210 | } 211 | ``` 212 | 213 | 214 | 215 | ### construct 216 | construct는 템플릿 매개 변수에 전달된 형식의 인스턴스를 작성하는 팩토리 함수를 반환한다. 217 | 이 함수의 인자 값을 생성자의 인수로 전달한다. 218 | 타입뿐만 아니라 템플릿 템플릿 매개 변수를 전달할 수 있으며, 이 경우 팩토리 함수의 인수에서 템플릿 매개 변수가 결정된다. 219 | 샘플은 X 타입과 클래스 템플릿 Y의 인스턴스를 생성한다. 220 | ``` 221 | #include 222 | namespace hof = boost::hof; 223 | 224 | struct X { 225 | X(int, double, char const*) {} 226 | }; 227 | 228 | template 229 | struct Y { 230 | Y(T, U, V) {} 231 | }; 232 | 233 | int main() { 234 | const auto createX = hof::construct(); 235 | createX(1, 3.14, "hello"); 236 | 237 | const auto createY = hof::construct(); 238 | createY(true, nullptr, 2.f); 239 | } 240 | ``` 241 | 242 | 243 | 244 | ## BOOST_HOF_LIFT 245 | BOOST_HOF_LIFT는 함수 템플릿 또는 함수 객체 템플릿과 오버로드 함수를 제네릭 람다에 래핑한다. 246 | 일반적으로 함수 템플릿은 다른 고차 함수에 전달하는 경우 타입을 명시하고 인스턴스화 해야한다. 247 | 오버로드 함수도 마찬가지로 어떤 오버로드를 전달 하는가를 캐스팅 해야한다. 248 | 249 | 이미지 예 250 | ``` 251 | std::vector< int > v; 252 | ``` 253 | 가 있다며 함수 템플릿의 경우 254 | ``` 255 | template 256 | T my_add(T a, T b); 257 | ... 258 | std::accumulate(v.begin(), v,end(), 0, &my_sum); 259 | ``` 260 | 261 | 오버로드 함수의 경우 262 | ``` 263 | int my_add(int a, int b); 264 | double my_add(double a, double b); 265 | std::string my_add(std::string a, std::string b); 266 | ... 267 | std::accumulate(v.begin(), v.end(), static_cast(my_add)); 268 | ``` 269 | 270 | 같은 것이 필요하다. 271 | BOOST_HOF_LIFT는 제네릭 람다로 래핑 해준다. 272 | `[my_add](auto&&... args) { return my_add(std::forward(args...); }` 같은 이미지이다. 273 | 274 | 함수 템플릿도 오버로드 함수를 아래와 같이 쓸 수 있다. 275 | ``` 276 | std::accumulate(v.begin(), v.end(), BOOST_HOF_LIFT(my_add)); 277 | ``` 278 | 279 | 280 | 281 | ### tap 282 | tap은 pipable에서 사용 되는 것을 상정하고 있다. pipable의 중간 값을 볼 수 있다. 283 | ``` 284 | #include 285 | #include 286 | namespace hof = boost::hof; 287 | 288 | constexpr int add(int a, int b) { 289 | return a + b; 290 | } 291 | 292 | template 293 | void print(char const* key, T const& value) { 294 | std::cout << key << ": " << value << std::endl; 295 | } 296 | 297 | int main() 298 | { 299 | auto added = hof::pipable(add); 300 | auto result = 3 | added(5) | hof::tap([](auto value) { print("temp", value); }) | added(7); 301 | print("result", result); 302 | } 303 | ``` 304 | 305 | 출력 306 |
307 | temp: 8
308 | result: 15
309 | 
310 | 311 | 312 | 313 | ## 참고 314 | - [Boost.HOFについて](https://nekko1119.hatenablog.com/entry/2018/08/24/010924) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Choi HeungBae 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Log.md: -------------------------------------------------------------------------------- 1 | # Boost.Log 2 | [공식 문서](http://www.boost.org/doc/libs/1_73_0/libs/log/doc/html/index.html ) 3 | [샘플](http://bitter-development.blogspot.kr/2013/08/boostlog-20.html ) 4 | 5 | https://boostjp.github.io/tips/logging.html 6 | - (일어) [Boost.Log 사용하기](http://faithandbrave.hateblo.jp/entry/20130725/1374736211 ) 7 | - (일어) [boost.Log 사용 방법을 공부](http://d.hatena.ne.jp/yamada28go/20140215/1392470561 ) 8 | - (일어) [콘솔 화면과 파일에 로깅](http://daisukekobayashi.com/blog/boost-log-logging-console-windows-and-file ) 9 | - (일어) [파일 사이즈에 의한 로테이션](http://faithandbrave.hateblo.jp/entry/20130801/1375340888 ) 10 | - (일어) [파일에 출력하기](http://kkayataka.hatenablog.com/entry/2013/07/29/062652 ) 11 | - [Boost.log Advaced 사용법 ](http://miragecore.tistory.com/entry/Boostlog-Addvaced-%EC%82%AC%EC%9A%A9%EB%B2%95 ) 12 | - http://boost-log.sourceforge.net/libs/log/doc/html/index.html 13 | - (일어) [Boost.Log 2.0](http://satoshinote.blogspot.kr/2013/06/boostlog-20_15.html ) 14 | - (일어) [설치와 호환성@Boost.Log 2.0](http://satoshinote.blogspot.kr/2013/06/boostlog-20_16.html ) 15 | - (일어) [정의@Boost.Log 2.0](http://satoshinote.blogspot.kr/2013/06/boostlog-20_17.html ) 16 | - (일어) [동기@Boost.Log 2.0](http://satoshinote.blogspot.kr/2013/06/boostlog-20.html ) 17 | - (일어) [구성과 라이브러리 빌드@Boost.Log 2.0](http://satoshinote.blogspot.kr/2013/06/boostlog-20_3584.html ) 18 | - (일어) non-trivial한 Boost.Log 사용 방법 19 | - http://qiita.com/termoshtt/items/071fcefef4720dcd790d 20 | - http://qiita.com/termoshtt/items/ee9a6df5d4a5f30a86f6 21 | - http://qiita.com/termoshtt/items/6b25084556f8a69239cb 22 | - http://qiita.com/termoshtt/items/9c856562fe8a8c42560c 23 | - (일어) [Boost.Log와 fluentd로 시작하는 로그 활용술](http://www.slideshare.net/termoshtt/boostlogfluentd ) -------------------------------------------------------------------------------- /OverloadedFunction.md: -------------------------------------------------------------------------------- 1 | ## 개요 2 | 복수의 함수를 하나의 함수 오브젝트로 모아서 사용한다. 3 | 4 | ``` 5 | // 출처: http://d.hatena.ne.jp/osyo-manga/20140213/1392299962 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | std::string to_string(int n) 13 | { 14 | return boost::lexical_cast(n); 15 | } 16 | 17 | int to_int(std::string str) 18 | { 19 | return boost::lexical_cast(str); 20 | } 21 | 22 | 23 | int main() 24 | { 25 | 26 | boost::overloaded_function< 27 | std::string(int), 28 | int(std::string) 29 | > multi(&to_string, &to_int); 30 | 31 | // 함수 오버라이드와 같이 인수의 타입에 따라서 호출 함수가 정해진다. 32 | std::cout << multi(10) + "-mami" << std::endl; 33 | std::cout << multi("42") * 2 << std::endl; 34 | 35 | return 0; 36 | } 37 | ``` 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Boost 라이브러리 학습 2 | [Boost 라이브러리 공식 사이트](https://www.boost.org/ ) 3 | 4 |
5 | 6 | - [빌드 및 사용하기](./build.md ) 7 | - [Pool](./pool.md ) 8 | - [in_place](./in_place.md ) 9 | - [Boost.ScopeExit](./SCOPE_EXIT.md ) 10 | - [Program Options](./program_options.md ) 11 | - [overloaded function](./OverloadedFunction.md ) 12 | - [numeric::interval](./numeric-interval.md ) 13 | - [predef](./predef.md ) 14 | - [PP](./PP.md ) 15 | - [date_time](./date_time.md ) 16 | - [siglans2](./signals2.md ) 17 | - [Log](./Log.md ) 18 | - 병렬 프로그래밍, 네트워크 프로그래밍 19 | - [cobalt](./cobalt.md ) 20 | - 컨테이너, 데이터셋 21 | - [circular_buffer](./circular_buffer.md ) 22 | - [reference_wrapper](./reference_wrapper.md ) 23 | - [multi_index](./multi_index.md ) 24 | - 템플릿 프로그래밍 관련 25 | - [TTI](./TTI.md ) 26 | - [HOF](./HOF.md ) 27 | - [DLL](./dll.md ) 28 | - [CRC](./CRC.md ) 29 | - [Geometry](./Geometry.md ) 30 | - [Algorithm](./algorithm.md ) 31 | - [variant](./variant.md ) 32 | - [UUID](./UUID.md ) 33 | - [timer](./timer.md ) 34 | - [string](./string.md) 35 | 36 | 37 | 38 |
39 | 40 | 41 | # 강연 42 | - [Boost 라이브러리와 C++11 - 강연문서와 예제코드](http://jacking.tistory.com/909) 43 | - [Boost 라이브러리와 C++11](https://www.youtube.com/watch?v=mwDDUuoOgQI) 44 | - [Boost.multi_index 강연 문서와 영상](http://jacking.tistory.com/994) 45 | - [KGC 2012 강연 자료 - Boost.Asio를 이용한 네트웍 프로그래밍](http://jacking.tistory.com/1022) 46 | 47 | # 문서 및 책 48 | - [Boost 라이브러리의 모든 것(1.60 버전까지)](https://docs.google.com/presentation/d/1lvLCdsMSMb-KK_FjNZK1hhBN-koTb1sLV_1Wi7OqBQk/edit?usp=sharing ) 49 | - [Boost의 컨테이너들 소개](https://docs.google.com/presentation/d/1tAS_s0xsHV71rgAkRaPS1YMrDakVhHx7e6qD-LiSHp4/edit?usp=sharing ) 50 | - [e-book 'Boost.Asio를 이용한 네트워크 프로그래밍'](http://www.hanb.co.kr/ebook/look.html?isbn=9788968486111) -------------------------------------------------------------------------------- /SCOPE_EXIT.md: -------------------------------------------------------------------------------- 1 | # 개요 2 | - 함수를 나올 때 호출될 코드를 정의하여 자동으로 호출 되도록 한다 3 | - (일본어) https://boostjp.github.io/tips/scope_guard.html 4 | - (일본어) C++11 람다 대응 http://d.hatena.ne.jp/faith_and_brave/20111125/1322199381 5 | - (일본어) this 캡쳐하기 http://d.hatena.ne.jp/faith_and_brave/20120703/1341298054 6 | 7 | 8 | # 스코프 내의 모든 변수를 캡쳐하기(C++11 전용) 9 | BOOST_SCOPE_EXIT_ALL을 사용한다. 클래스의 멤버 변수도 사용할 수 있음 10 | ``` 11 | CPacketSend kPacketSend( SAD_REP_CHECK_ACCOUNT ); 12 | BYTE nErrorCode = E_SAI_REP_CHECK_ACCOUNT::FLAG_CHECK_OK; 13 | 14 | BOOST_SCOPE_EXIT_ALL(&) 15 | { 16 | if( nErrorCode != E_SAI_REP_CHECK_ACCOUNT::FLAG_CHECK_OK ) 17 | { 18 | kPacketSend << nErrorCode; 19 | kPacketSend << nClientSocketIndexInLoginServer; 20 | kPacketSend << dwLoginUniqueSocketID; 21 | kPacketSend << iLoginServerNumber; 22 | GET_NETWORK_INTERFACE()->SendToServer( iServer, kPacketSend); 23 | } 24 | }; 25 | ``` 26 | 27 | 28 | # BOOST_SCOPE_EXIT를 사용할 때 조심할 점 29 | 이것을 사용하는 스코프 내에서 BOOST_SCOPE_EXIT를 정의하기 전에 return 문을 사용하면 안된다. 30 | ``` 31 | void Check() 32 | { 33 | ........... 34 | if( ... ) 35 | { 36 | return; 37 | } 38 | 39 | // 아래가 호출되지 않는다 40 | BOOST_SCOPE_EXIT_ALL(&) 41 | { 42 | }; 43 | } 44 | ``` 45 | 46 | 올바르게 사용하려면 아래와 같이 바꾸어야 한다. 47 | ``` 48 | void Check() 49 | { 50 | ........... 51 | // 아래가 호출되지 않는다 52 | BOOST_SCOPE_EXIT_ALL(&) 53 | { 54 | }; 55 | 56 | .... 57 | if( ... ) 58 | { 59 | return; 60 | } 61 | 62 | 63 | } 64 | ``` 65 | 66 | # BOOST_SCOPE_EXIT 67 | `BOOST_SCOPE_EXIT_END` 매크로를 쌍으로 사용해야 한다 68 | ``` 69 | BOOST_SCOPE_EXIT((&x)(&y)) { 70 | x = x + 1; 71 | y = y + 1; 72 | } BOOST_SCOPE_EXIT_END 73 | ``` -------------------------------------------------------------------------------- /TTI.md: -------------------------------------------------------------------------------- 1 | # Boost.TTI 2 | Boost.TTI는 어떤 타입이 멤버나 메소드를 가지고 있는지 아닌지를 판단하기 위한 라이브러리이다. 3 | BOOST_MPL_HAS_XXX_TRAIT_DEF 의 확장판이라고 볼 수 있다. 4 | 5 | 6 | ## 간단한 사용 방법 7 | BOOST_MPL_HAS_XXX_TRAIT_DEF와 비슷하게 매크로 함수를 사용하여 메타 함수를 정의한다. 8 | ``` 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | namespace mpl = boost::mpl; 15 | 16 | 17 | // has_xxx 를 정의한다 18 | BOOST_TTI_HAS_TYPE(value_type) // has_type_value_type 19 | BOOST_TTI_HAS_MEMBER_DATA(value) // has_member_data_value 20 | BOOST_TTI_HAS_MEMBER_FUNCTION(func) // has_member_function_funcg 21 | 22 | 23 | struct X{ 24 | typedef int value_type; 25 | value_type value; 26 | 27 | void func(int, int){} 28 | int func(float){ return 0; } 29 | }; 30 | 31 | 32 | // value_type 유무 33 | BOOST_MPL_ASSERT((has_type_value_type)); 34 | 35 | // value_type의 타입을 지정하고 체크도 가능하다 36 | BOOST_MPL_ASSERT ((has_type_value_type)); 37 | BOOST_MPL_ASSERT_NOT((has_type_value_type)); 38 | 39 | 40 | // 프로퍼티 value 유무 41 | // value의 타입을 지정한다 42 | BOOST_MPL_ASSERT ((has_member_data_value)); 43 | BOOST_MPL_ASSERT_NOT((has_member_data_value)); 44 | 45 | 46 | // 메소드 func 유무 47 | // 반환 값 타입과 인수 타입을 지정한다 48 | BOOST_MPL_ASSERT(( 49 | has_member_function_func< 50 | X, 51 | void, // 반환 값 타입 52 | mpl::vector // 인수는 mpl::vector 로 넘긴다 53 | > 54 | )); 55 | 56 | // 오버로드 하고 있어도 체크 할 수 있다 57 | BOOST_MPL_ASSERT(( 58 | has_member_function_func< 59 | X, 60 | int, 61 | mpl::vector 62 | > 63 | )); 64 | 65 | BOOST_MPL_ASSERT_NOT((has_member_function_func)); 66 | 67 | int main(){} 68 | ``` 69 | 70 | 이런 식으로 정의한 메타 함수에 타입을 넘겨서 사용한다. 71 | 또 BOOST_TTI_TRAIT_{macro name} 로 메타 함수 이름을 지정할 수도 있다. 72 | ``` 73 | // has_value 라는 메타 함수 이름으로 정의 74 | BOOST_TTI_TRAIT_HAS_MEMBER_DATA(has_value, value) 75 | 76 | struct X{ 77 | int value; 78 | }; 79 | 80 | BOOST_MPL_ASSERT((boost::tti::has_value)); 81 | ``` 82 | 83 | 84 | ### ::type을 전개 85 | 메타 프로그래밍을 하고 있을 때 아래와 같이 `::type`을 전개해가 바라는 경우가 있다. 86 | ``` 87 | #include 88 | 89 | BOOST_TTI_HAS_TYPE(value_type) 90 | 91 | template 92 | struct element_value_type{ 93 | typedef typename T::value_type type; 94 | }; 95 | 96 | template 97 | struct X 98 | // ::type, element_type::type> 라고 전개하기 바란다 99 | : has_type_value_type, element_value_type >{}; 100 | ``` 101 | 102 | 안타깝게 `has_type_value_type` 내에서는 `::type` 전개는 할 수 없다. 103 | 여기에서 Boost.TTI 에서 준비한 헬퍼 함수를 사용한다. 104 | ``` 105 | #include 106 | // 추가 107 | #include 108 | 109 | BOOST_TTI_HAS_TYPE(value_type) 110 | 111 | template 112 | struct element_value_type{ 113 | typedef typename T::value_type type; 114 | }; 115 | 116 | template 117 | struct X 118 | // boost::tti::mf_has_type 119 | // Boost.MPL의 placeholders를 사용하여 부분 적용된다 120 | : boost::tti::mf_has_type< 121 | has_type_value_type, 122 | mpl::identity, 123 | element_value_type 124 | > 125 | {}; 126 | ``` 127 | 128 | 이것으로 `has_type_value_type`에 `::type`을 전개한 결과가 적용된다. 129 | 130 | 131 | ### 실제로 사용해보기 132 | 다음과 같은 함수를 정의해 본다. 133 | 1. T가 value_type 타입의 value를 멤버로서 가지고 있는 경우는 value를 반환 134 | 2. 이 이외의 경우는 T를 반환 135 | 136 | ``` 137 | #include 138 | #include 139 | #include 140 | #include 141 | #include 142 | #include 143 | #include 144 | 145 | namespace mpl = boost::mpl; 146 | 147 | BOOST_TTI_HAS_TYPE(value_type) // has_type_value_type 148 | BOOST_TTI_HAS_MEMBER_DATA(value) // has_member_data_value 149 | 150 | template 151 | struct element_value_type{ 152 | typedef typename T::value_type type; 153 | }; 154 | 155 | template 156 | struct trivial_get_value : 157 | mpl::and_< 158 | boost::is_class, 159 | has_type_value_type, 160 | boost::tti::mf_has_member_data< 161 | has_member_data_value, 162 | mpl::identity, 163 | element_value_type 164 | > 165 | >::type 166 | {}; 167 | 168 | template 169 | typename T::value_type 170 | get_value(T const& t, typename boost::enable_if >::type* =0){ 171 | return t.value; 172 | } 173 | 174 | template 175 | T const& 176 | get_value(T const& t, typename boost::disable_if >::type* =0){ 177 | return t; 178 | } 179 | 180 | 181 | struct X{ 182 | typedef int value_type; 183 | value_type value; 184 | }; 185 | 186 | struct hoge{}; 187 | 188 | 189 | int 190 | main(){ 191 | X x = {4}; 192 | int n = get_value(x); 193 | 194 | hoge h; 195 | get_value(h); 196 | get_value(0); 197 | return 0; 198 | } 199 | ``` 200 | 201 | `trivial_get_value` 에서 `get_value` 기능을 만족하고 있는지를 체크하고 있다. 202 | 203 | ### 주의 204 | Boost.TTI 의 메타 함수에 클래스 이외의 타입을 넘기면 컴파일 에러(false를 반환하는 것이 아닌 )가 되므로 주의한다. 205 | 206 | 207 | 208 | ## 멤버를 가지고 있는지 조사하는 예제 코드 209 | 210 | ``` 211 | #include 212 | 213 | 214 | BOOST_TTI_HAS_MEMBER_FUNCTION(close) 215 | // => has_member_function_close 216 | 217 | struct custom_deleter{ 218 | template 219 | void 220 | operator ()(T* p, 221 | typename std::enable_if< 222 | has_member_function_close::value 223 | >::type* = 0 224 | ) const{ 225 | p->close(); 226 | delete p; 227 | } 228 | template 229 | void 230 | operator ()(T* p, 231 | typename std::enable_if< 232 | has_member_function_close::value 233 | >::type* = 0 234 | ) const{ 235 | p->close(100); 236 | delete p; 237 | } 238 | }; 239 | 240 | 241 | #include 242 | #include 243 | #include 244 | 245 | 246 | struct Hoge{ 247 | Hoge() {} 248 | ~Hoge() {} 249 | void close() { 250 | std::cout << "Hoge::close" << std::endl; 251 | }; 252 | }; 253 | 254 | struct Fuga{ 255 | Fuga() {} 256 | ~Fuga() {} 257 | void close(int i) { 258 | std::cout << "Fuga::close" << std::endl; 259 | }; 260 | }; 261 | 262 | 263 | int 264 | main(){ 265 | { 266 | std::shared_ptr hoge(new Hoge(), custom_deleter()); 267 | std::shared_ptr fuga(new Fuga(), custom_deleter()); 268 | } 269 | return 0; 270 | } 271 | ``` 272 | 273 | 274 | ## C++03에서 특정 멤버 함수가 존재하는지를 판정 275 | Boost.TTI의 `has_member_function` 기능을 사용하여 특정 멤버 함수를 가지고 있는지 판정한다. 276 | C++11의 SFINAE Expression를 사용할 수 없는 경우에 유용하다. 277 | ``` 278 | #include 279 | 280 | struct X { 281 | int foo(double, char); 282 | }; 283 | 284 | namespace my_namespace { 285 | // foo() 멤버 함수를 가지고 있는지 판정하기 위한 메타 함수를 정의한다 286 | BOOST_TTI_HAS_MEMBER_FUNCTION(foo) 287 | } 288 | 289 | int main() 290 | { 291 | static_assert( 292 | my_namespace::has_member_function_foo< 293 | X, // 대상의 타입 294 | int, // 반환 값 타입 295 | boost::mpl::vector // 파라메터 타입 296 | >::value == true, 297 | "must be true"); 298 | } 299 | ``` 300 | 301 | 302 | ## 위 글들의 출처 303 | - https://osyo-manga.hatenadiary.org/entry/20111230/1325213907 -------------------------------------------------------------------------------- /UUID.md: -------------------------------------------------------------------------------- 1 | ### 개용 2 | 범용적인 unique한 식별자. 3 | 16바이트로 표시하는 유니크한 값을 생성할 수 있다. 4 | 5 | ``` 6 | //출처: http://www.kmonos.net/alang/boost/classes/uuid.html 7 | #include 8 | #include 9 | #include 10 | #include 11 | using namespace boost::uuids; 12 | 13 | int main() 14 | { 15 | uuid u1 = random_generator()(); 16 | uuid u2 = random_generator()(); 17 | uuid u3 = random_generator()(); 18 | std::cout << u1 << std::endl; 19 | std::cout << u2 << std::endl; 20 | std::cout << u3 << std::endl; 21 | 22 | uuid base = string_generator()("0123456789abcdef0123456789abcdef"); 23 | std::cout << base << std::endl; 24 | 25 | name_generator gen(base); 26 | uuid u4 = gen("www.kmonos.net"); 27 | uuid u5 = gen("boost.org"); 28 | uuid u6 = gen("www.kmonos.net"); 29 | std::cout << u4 << std::endl; 30 | std::cout << u5 << std::endl; 31 | std::cout << u6 << std::endl; 32 | } 33 | ``` 34 | -------------------------------------------------------------------------------- /algorithm.md: -------------------------------------------------------------------------------- 1 | # Algorithm 2 | 3 | ## clamp() 4 | 수치 변화를 지정 범위 내로 하기 5 | hp의 값이 최소 0 ~ maxHP 사이가 되도록 한다. 6 | 7 | ``` 8 | #include 9 | 10 | void hpchange(int addhp){ 11 | hp = boost::algorithm::clamp(hp + addhp, 0, maxHp); 12 | } 13 | ``` 14 | 15 | 16 | ## clamp_range() 17 | clamp()에 의한 값의 변환 처리를 값의 Range에 대응한다. 18 | 이 함수는 OutputIterator로 변환 후의 Range을 반환한다. 19 | ``` 20 | #include 21 | #include 22 | #include 23 | 24 | int main() 25 | { 26 | std::vector v = {-1, 2, 5, 8, 11}; 27 | 28 | // Rangeの値を0から10の範囲に収める 29 | boost::algorithm::clamp_range(v, v.begin(), 0, 10); 30 | 31 | for (int x : v) { 32 | std::cout << x << std::endl; 33 | } 34 | } 35 | ``` 36 | 결과: 37 |
 38 | 0
 39 | 2
 40 | 5
 41 | 8
 42 | 10
 43 | 
44 | 45 | 46 | ## all_of 47 | C++11의 all_of의 Range 버전 48 | ``` 49 | #include 50 | #include 51 | #include 52 | 53 | bool is_even(int x) { return x % 2 == 0; } 54 | 55 | int main() 56 | { 57 | const std::vector v = {2, 4, 6, 8, 10}; 58 | 59 | std::cout << std::boolalpha; 60 | 61 | // 이터레이터 버전 62 | { 63 | const bool result = boost::algorithm::all_of(v.begin(), v.end(), is_even); 64 | std::cout << result << std::endl; 65 | } 66 | 67 | // Range 버전 68 | { 69 | const bool result = boost::algorithm::all_of(v, is_even); 70 | std::cout << result << std::endl; 71 | } 72 | } 73 | ``` 74 | 결과: 75 |
 76 | true
 77 | true
 78 | 
79 | 80 | 81 | ## hex() 82 | 16진수 표현의 문자열을 10진수 표현으로 바꾼다. 83 | ``` 84 | #include 85 | #include 86 | #include 87 | #include 88 | 89 | int main() 90 | { 91 | std::string s = "abc"; 92 | 93 | std::string out; 94 | boost::algorithm::hex(s, std::back_inserter(out)); 95 | 96 | std::cout << out << std::endl; 97 | } 98 | ``` 99 | 결과: 100 |
101 | 616263
102 | 
103 | 104 | 105 | ## unhex() 106 | 10 진수 표현 문자열을 16진수 표현으로 바꾼다. 107 | ``` 108 | #include 109 | #include 110 | #include 111 | #include 112 | 113 | int main() 114 | { 115 | std::string s = "616263"; 116 | 117 | std::string out; 118 | boost::algorithm::unhex(s, std::back_inserter(out)); 119 | 120 | std::cout << out << std::endl; 121 | } 122 | ``` 123 | 결과: 124 |
125 | abc
126 | 
127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /boost_container/codes/circular_buffer_01/circular_buffer_01.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/codes/circular_buffer_01/circular_buffer_01.cpp -------------------------------------------------------------------------------- /boost_container/codes/circular_buffer_01/circular_buffer_01.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {833DA434-4B8C-4BAD-9ED9-8F7C4A31F75D} 15 | Win32Proj 16 | circular_buffer_01 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /boost_container/codes/circular_buffer_01/circular_buffer_01.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /boost_container/codes/circular_buffer_02/circular_buffer_02.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/codes/circular_buffer_02/circular_buffer_02.cpp -------------------------------------------------------------------------------- /boost_container/codes/circular_buffer_02/circular_buffer_02.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {894ADEDF-5CEA-46E3-82B6-864E0F5E43B4} 15 | Win32Proj 16 | circular_buffer_02 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /boost_container/codes/circular_buffer_02/circular_buffer_02.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /boost_container/codes/circular_buffer_03/circular_buffer_03.cpp: -------------------------------------------------------------------------------- 1 | // 버퍼 접근 2 | // 출처: https://sites.google.com/site/boostjp/tips/circular_buffer 3 | 4 | #include 5 | #include 6 | 7 | void disp( char x ) 8 | { 9 | std::cout << x << ' '; 10 | } 11 | 12 | int main() 13 | { 14 | boost::circular_buffer c_buf( 5 ); 15 | 16 | c_buf.push_front( 'A' ); 17 | c_buf.push_front( 'B' ); 18 | c_buf.push_front( 'C' ); 19 | // ___ ___ ___ ___ ___ 20 | std::for_each( c_buf.begin(), c_buf.end(), disp ); // |_C_|_B_|_A_|___|___| 21 | std::cout << std::endl; 22 | 23 | 24 | boost::circular_buffer::iterator it = c_buf.begin(); 25 | 26 | std::cout << c_buf.front() << std::endl; // 'C' 27 | std::cout << *it << std::endl; // 'C' 28 | 29 | std::cout << c_buf.back() << std::endl; // 'A' 30 | std::cout << *( c_buf.end() - 1 ) << std::endl; // 'A' 31 | // std::cout << *c_buf.end() << std::endl; // 이것은 불가능 32 | std::cout << std::endl; 33 | 34 | c_buf.push_front( 'D' ); 35 | c_buf.push_front( 'E' ); 36 | c_buf.push_front( 'F' ); 37 | // ___ ___ ___ ___ ___ 38 | std::for_each( c_buf.begin(), c_buf.end(), disp ); // |_F_|_E_|_D_|_C_|_B_| 39 | std::cout << std::endl; 40 | 41 | std::cout << *it << std::endl; // 'C' 42 | std::cout << std::endl; 43 | 44 | c_buf.push_front( 'G' ); 45 | c_buf.push_front( 'H' ); 46 | // ___ ___ ___ ___ ___ 47 | std::for_each( c_buf.begin(), c_buf.end(), disp ); // |_H_|_G_|_F_|_E_|_D_| 48 | std::cout << std::endl; 49 | 50 | // std::cout << *it << std::endl; // 'C'는 사라졌으므로 이것은 불가능 51 | 52 | // ----------------------------- 53 | // 임의 접근 54 | // ----------------------------- 55 | std::cout << c_buf[0] << std::endl; // 'H' 56 | std::cout << c_buf.at(2) << std::endl; // c_buf[2]와 같은 'F' 57 | std::cout << std::endl; 58 | 59 | return 0; 60 | } -------------------------------------------------------------------------------- /boost_container/codes/circular_buffer_03/circular_buffer_03.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {F99882F4-A588-40BA-B0E2-6182DA04E091} 15 | Win32Proj 16 | circular_buffer_03 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /boost_container/codes/circular_buffer_03/circular_buffer_03.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /boost_container/codes/circular_buffer_04/circular_buffer_04.cpp: -------------------------------------------------------------------------------- 1 | // 실제 메모리 주소 2 | // 출처: https://sites.google.com/site/boostjp/tips/circular_buffer 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | // 메모리 표시 9 | void mem_dump( char *p, int num ) 10 | { 11 | std::for_each( p, p+num, [] (char data) { std::cout << data << ' '; }); 12 | std::cout << std::endl; 13 | } 14 | 15 | int main() 16 | { 17 | boost::circular_buffer c_buf( 5 ); 18 | c_buf.push_front( 'A' ); 19 | c_buf.push_front( 'B' ); 20 | c_buf.push_front( 'C' ); 21 | c_buf.push_front( 'D' ); 22 | c_buf.push_front( 'E' ); 23 | c_buf.push_front( 'F' ); // 이 이후 앞의 'A'부터 덮어쒸워진다 24 | c_buf.push_front( 'G' ); 25 | c_buf.push_front( 'H' ); 26 | 27 | // -------------------------------------------------------------------------- 28 | // 순환 버퍼의 메모리 주소 이미지 29 | // ___ ___ ___ ___ ___ 30 | // |_H_|_G_|_F_|_E_|_D_| 31 | // -------------------------------------------------------------------------- 32 | std::for_each( c_buf.begin(), c_buf.end(), [] (char data) { std::cout << data << ' '; }); 33 | std::cout << std::endl; 34 | 35 | // ------------------------------ 36 | // 실제 메모리 주소를 확인 37 | // ------------------------------ 38 | int num1 = c_buf.array_one().second; // begin()에서 끝까지의 개수 '3' 39 | int num2 = c_buf.array_two().second; // 실제 메모리 선두에서 end()까지의 개수는 '2' 40 | std::cout << num1 << std::endl; 41 | std::cout << num2 << std::endl; 42 | 43 | // -------------------------------------------------------------------------- 44 | // 실제 메모리 주소 45 | // ___ ___ ___ ___ ___ 46 | // |_E_|_D_|_H_|_F_|_G_| 47 | // | +--------------- 'H'가 begin() 위치, 이 위치를 포함해서 3개 연속 48 | // +------------------- 'D'가 end() 위치. 선두 'E'를 포함해서 2개 연속2 49 | // -------------------------------------------------------------------------- 50 | char* p1 = c_buf.array_one().first; 51 | char* p2 = c_buf.array_two().first; 52 | mem_dump( p1, num1 ); // begin()에서 실제 메모리 끝까지 출력 53 | mem_dump( p2, num2 ); // 실제 메모리 선두에서 end()까지 출력 54 | 55 | c_buf.pop_back(); // 마지막을 삭제해본다. 56 | 57 | std::cout << std::endl; 58 | 59 | 60 | // -------------------------------------------------------------------------- 61 | // 순환 버퍼의 메모리 주소 이미지 62 | // ___ ___ ___ ___ ___ 63 | // |_H_|_G_|_F_|_E_|___| 64 | // -------------------------------------------------------------------------- 65 | std::for_each( c_buf.begin(), c_buf.end(), [] (char data) { std::cout << data << ' '; }); 66 | std::cout << std::endl; 67 | 68 | num1 = c_buf.array_one().second; 69 | num2 = c_buf.array_two().second; 70 | std::cout << num1 << std::endl; 71 | std::cout << num2 << std::endl; 72 | 73 | // -------------------------------------------------------------------------- 74 | // 실제 메모리 주소 75 | // ___ ___ ___ ___ ___ 76 | // |_E_|___|_H_|_F_|_G_| 77 | // | +--------------- 'H'가 begin()위치. 이 위치를 포함해서 3개 연속 78 | // +----------------------- 'E'가 end() 위치. 선두'E'를 포함해서 1개 연속 79 | // -------------------------------------------------------------------------- 80 | p1 = c_buf.array_one().first; 81 | p2 = c_buf.array_two().first; 82 | mem_dump( p1, num1 ); 83 | mem_dump( p2, num2 ); 84 | 85 | // linearize()을 사용하면 레거시 C의 모습으로 기록 가능 86 | mem_dump( c_buf.linearize(), 4 ); 87 | 88 | return 0; 89 | } -------------------------------------------------------------------------------- /boost_container/codes/circular_buffer_04/circular_buffer_04.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {F8DBC765-9EDD-4F16-A373-450D33BC3368} 15 | Win32Proj 16 | circular_buffer_04 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /boost_container/codes/circular_buffer_04/circular_buffer_04.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /boost_container/codes/circular_buffer_05/circular_buffer_05.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/codes/circular_buffer_05/circular_buffer_05.cpp -------------------------------------------------------------------------------- /boost_container/codes/circular_buffer_05/circular_buffer_05.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {48E6898C-A822-4AA8-9FAE-336E92DA0FFE} 15 | Win32Proj 16 | circular_buffer_05 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /boost_container/codes/circular_buffer_05/circular_buffer_05.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /boost_container/codes/flat_map_01/flat_tree_01.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | int main() 5 | { 6 | { 7 | boost::container::flat_map map; 8 | map.insert(std::make_pair(1, 1.1f)); 9 | map.insert(std::make_pair(-1, -1.1f)); 10 | map.insert(std::make_pair(3, 3.3f)); 11 | map.insert(std::make_pair(2, 2.2f)); 12 | 13 | std::cout << map[1] << std::endl; 14 | } 15 | 16 | { 17 | boost::container::flat_map map; 18 | map.insert(std::make_pair(1, 1.1f)); 19 | map.insert(std::make_pair(4, 4.4f)); 20 | map.insert(std::make_pair(3, 3.3f)); 21 | map.insert(std::make_pair(2, 2.2f)); 22 | 23 | std::cout << map[4] << std::endl; 24 | } 25 | 26 | return 0; 27 | } -------------------------------------------------------------------------------- /boost_container/codes/flat_map_01/flat_tree_01.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {5CC89CF2-ED1A-4DE1-8786-72192081DD76} 15 | Win32Proj 16 | flat_tree_01 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /boost_container/codes/flat_map_01/flat_tree_01.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /boost_container/codes/multi_index_01/multi_index_01.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/codes/multi_index_01/multi_index_01.cpp -------------------------------------------------------------------------------- /boost_container/codes/multi_index_01/multi_index_01.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {B306BEB8-D4ED-4D47-9A44-1D0BB3BA7CFE} 15 | Win32Proj 16 | multi_index_01 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /boost_container/codes/multi_index_01/multi_index_01.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /boost_container/codes/multi_index_02/multi_index_02.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/codes/multi_index_02/multi_index_02.cpp -------------------------------------------------------------------------------- /boost_container/codes/multi_index_02/multi_index_02.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {52C8840F-FDB8-4477-9BD5-BECEA32F2783} 15 | Win32Proj 16 | multi_index_02 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /boost_container/codes/multi_index_02/multi_index_02.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /boost_container/codes/multi_index_03/multi_index_03.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/codes/multi_index_03/multi_index_03.cpp -------------------------------------------------------------------------------- /boost_container/codes/multi_index_03/multi_index_03.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {E86F0EE4-72BA-4068-AA7E-55452B840A95} 15 | Win32Proj 16 | multi_index_03 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /boost_container/codes/multi_index_03/multi_index_03.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /boost_container/codes/multi_index_04/multi_index_04.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/codes/multi_index_04/multi_index_04.cpp -------------------------------------------------------------------------------- /boost_container/codes/multi_index_04/multi_index_04.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {3ED2EDE0-02D7-4365-8B7F-BCE252451AA4} 15 | Win32Proj 16 | multi_index_04 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /boost_container/codes/multi_index_04/multi_index_04.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /boost_container/codes/multi_index_05/multi_index_05.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/codes/multi_index_05/multi_index_05.cpp -------------------------------------------------------------------------------- /boost_container/codes/multi_index_05/multi_index_05.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {0DDFE7DD-E8FA-4261-AAFC-BCAFD5826D3C} 15 | Win32Proj 16 | multi_index_05 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /boost_container/codes/multi_index_05/multi_index_05.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /boost_container/codes/multi_index_06/multi_index_06.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/codes/multi_index_06/multi_index_06.cpp -------------------------------------------------------------------------------- /boost_container/codes/multi_index_06/multi_index_06.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {D8E71D38-F8E1-4D16-975B-966D22CF7EE8} 15 | Win32Proj 16 | multi_index_06 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /boost_container/codes/multi_index_06/multi_index_06.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /boost_container/codes/multi_index_07/multi_index_07.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/codes/multi_index_07/multi_index_07.cpp -------------------------------------------------------------------------------- /boost_container/codes/multi_index_07/multi_index_07.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {230E9345-B805-4AC5-B42E-6556A2E5B6A4} 15 | Win32Proj 16 | multi_index_07 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /boost_container/codes/multi_index_07/multi_index_07.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /boost_container/codes/multi_index_08/multi_index_08.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/codes/multi_index_08/multi_index_08.cpp -------------------------------------------------------------------------------- /boost_container/codes/multi_index_08/multi_index_08.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {6E1C0A56-D8F1-4A41-8AF2-A8BA4CD96EA3} 15 | Win32Proj 16 | multi_index_08 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /boost_container/codes/multi_index_08/multi_index_08.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /boost_container/codes/multi_index_09/multi_index_09.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/codes/multi_index_09/multi_index_09.cpp -------------------------------------------------------------------------------- /boost_container/codes/multi_index_09/multi_index_09.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {C38FF7F8-4803-4AB5-95EE-065A6EBD1FCB} 15 | Win32Proj 16 | multi_index_09 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /boost_container/codes/multi_index_09/multi_index_09.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /boost_container/codes/stable_vector_01/stable_vector_01.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/codes/stable_vector_01/stable_vector_01.cpp -------------------------------------------------------------------------------- /boost_container/codes/stable_vector_01/stable_vector_01.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {1E87F3F7-99A0-4830-8937-711CCCF84EA4} 15 | Win32Proj 16 | stable_vector_01 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /boost_container/codes/stable_vector_01/stable_vector_01.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /boost_container/codes/stable_vector_02/stable_vector_02.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/codes/stable_vector_02/stable_vector_02.cpp -------------------------------------------------------------------------------- /boost_container/codes/stable_vector_02/stable_vector_02.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {AF947975-0295-4765-9B1A-F768D291E25B} 15 | Win32Proj 16 | stable_vector_02 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /boost_container/codes/stable_vector_02/stable_vector_02.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 소스 파일 20 | 21 | 22 | -------------------------------------------------------------------------------- /boost_container/codes/static_vector_01/static_vector_01.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/codes/static_vector_01/static_vector_01.cpp -------------------------------------------------------------------------------- /boost_container/codes/static_vector_01/static_vector_01.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {372FB2B5-8B74-4809-ABE3-6CEEB57AC8C6} 15 | Win32Proj 16 | static_vector_01 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /boost_container/codes/static_vector_01/static_vector_01.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /boost_container/codes/static_vector_02/static_vector_02.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/codes/static_vector_02/static_vector_02.cpp -------------------------------------------------------------------------------- /boost_container/codes/static_vector_02/static_vector_02.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {C48F44AF-1065-4862-8B73-A4364E6FA890} 15 | Win32Proj 16 | static_vector_02 17 | 18 | 19 | 20 | Application 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | Application 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /boost_container/codes/static_vector_02/static_vector_02.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /boost_container/flat_map-set.md: -------------------------------------------------------------------------------- 1 | ## flat_(multi)map/set 2 | - Map 같지만 Map 같지 않은… 3 | - 속은 vector 이다. 4 | - 순회, 참조가 빠르다. 5 | - 작은 메모리 사용 6 | - 추가,삭제는 느리다(단 N > 100 일 때). 7 | - 반복자 안정성이 없다. 8 | - 요소 수가 작은 경우 강추. 9 | 10 | 11 | ### flat_(multi)set 12 | - std::set 보다 작은 메모리 사용. 13 | - 요소 삽입에는 시간이 좀 걸리지만 lookup(검색)에서는 바이너리 서치를 사용할 수 있어서 빠르다. 14 | 15 | #### 예제 코드 1 16 | ```C++ 17 | // http://codezine.jp/article/detail/8259 18 | 19 | void memory_usage() { 20 | cout << "\n==== memory usage\n"; 21 | const int N = 10; 22 | 23 | { 24 | cout << "\n--- " << N << " items insertion into 'set'\n"; 25 | 26 | std::set,epi::mallocator> fs; 27 | for ( int i = 0; i < N; ++i ) { 28 | fs.insert(N-i-1); 29 | } 30 | 31 | for ( const int& item : fs ) { 32 | cout << setw(4) << item << " @ " << static_cast(&item) << endl; 33 | } 34 | cout << endl; 35 | } 36 | cout << endl; 37 | 38 | { 39 | cout << "\n--- " << N << " items insertion into 'flat_set'\n"; 40 | 41 | boost::container::flat_set,epi::mallocator> fs; 42 | for ( int i = 0; i < N; ++i ) { 43 | fs.insert(N-i-1); 44 | } 45 | 46 | for ( const int& item : fs ) { 47 | cout << setw(4) << item << " @ " << static_cast(&item) << endl; 48 | } 49 | cout << endl; 50 | } 51 | cout << endl; 52 | 53 | } 54 | ``` 55 | 56 | ![Boost.Container](resource/012.PNG "Boost.Container") 57 | flat_set은 메모리의 할당과 해방을 반복하면서 점차 영역을 넓히고 있다. 또 각 요소의 주소도 선두부터 말미까지 연속으로 나란하다. 58 | 59 | std::set에서는 오름차순/내림차순에서 소요 시간에 큰 차이는 없지만, flat_set은 내림차순에서 삽입이 꽤 약다. 60 | 요소를 리니어 하면서 오름차순으로 저장하지 않으면 삽입 때마다 복사가 빈발하게 발생한다. 61 | ![Boost.Container](resource/013.PNG "Boost.Container") 62 | 63 | 64 | #### 예제 코드 2 65 | 요소의 중복을 허용한 flat_multiset에 동일 값 요소를 다수 삽입한다. 66 | int 값의 첫째 자리를 무시하고 29,28,27,...2,1,0을 삽입한다. 67 | 첫째 자리를 무시하므로 29~20,19~10,9~0은 각각 같은 값 요소가 된다 68 | ```C++ 69 | // http://codezine.jp/article/detail/8259 70 | 71 | #include 72 | #include 73 | #include 74 | 75 | using namespace std; 76 | using namespace boost::container; 77 | 78 | template 79 | struct less1 { 80 | bool operator()(T x, T y) const { return x/10 < y / 10; } 81 | }; 82 | 83 | int main() { 84 | const int N = 30; 85 | 86 | { 87 | flat_multiset> fs; 88 | for ( int i = 0; i < N; ++i ) { 89 | fs.insert(N-i-1); 90 | } 91 | for ( int item : fs ) { 92 | cout << item << ' '; 93 | } 94 | cout << endl; 95 | } 96 | cout << endl; 97 | 98 | } 99 | ``` 100 | 101 | 동일 값 요소를 다수 삽입하면 삽입한 순서로 나란히 해준다. 102 | 약간은 코드를 읽어 본 결과 삽입 위치를 upper_bound로 결정하고 있었다. 103 | ![Boost.Container](resource/014.PNG "Boost.Container") 104 | 105 | 106 | 107 | ### flat_map_ 108 | 109 | #### 예제 프로그램 110 | - flat_map_01 111 | 112 | 113 | -------------------------------------------------------------------------------- /boost_container/heap.md: -------------------------------------------------------------------------------- 1 | ## Heap 2 | - Boost.Heap의 컨테이너는 표준 컨테이너처럼 메모리 할당기 및 비교 함수를 커스터마이즈 할 수 있는 Policy-based Design에 근거하고 있다. 3 | - 표준 컨테이너는 이들 설정이 템플릿 매개 변수 순서에 의존하고 있지만 Boost.Heap의 경우는 명명된 템플릿 매개 변수를 채용하고 있으므로 지정하는 순서는 사용자가 마음대로 정할 수 있다. 4 | - 우선 순위를 결정하기 위한 비교 함수를 커스텀마이즈 하고 싶다면 Boost.Heap컨테이너에 boost::heap::compare를 지정한다. 5 | 기본적으로 boost::heap::compare > 가 설정 되어 있다. 6 | - 메모리 할당기를 커스텀마이즈 하고 싶다면 Boost.Heap 컨테이너에 boost::heap::allocator를 지정한다. 7 | 기본적으로 boost::heap::compare > 가 설정 되어 있다. 8 | - Boost.Heap 컨테이너에서는 size() 멤버 함수가 기본적으로 상수 시간으로 계산된다. 9 | 이것은 크기를 위한 멤버 변수를 내부에 가지고 있는 것을 의미한다. 10 | size() 멤버 함수에 상수 시간이 필요 없는 경우, boost::heap::constant_time_size를 지정하여 선형 시간으로 할 수 있다. 11 | 기본적으로 boost::heap::constant_time_size 이 설정된다. 12 | 13 | ```C++ 14 | // http://faithandbrave.hateblo.jp/entry/20120510/1336641311 15 | 16 | #include 17 | #include 18 | 19 | namespace heap = boost::heap; 20 | 21 | int main () 22 | { 23 | heap::fibonacci_heap< 24 | int, 25 | heap::allocator>, 26 | heap::compare>, 27 | heap::constant_time_size 28 | > que; 29 | 30 | que.push(3); 31 | que.push(1); 32 | que.push(4); 33 | 34 | std::cout << "size: " << que.size() << std::endl; 35 | 36 | while (!que.empty()) { 37 | std::cout << que.top() << std::endl; 38 | que.pop(); 39 | } 40 | } 41 | ``` 42 |
43 | size: 3
44 | 1
45 | 3
46 | 4
47 | 
48 | 49 | 이 외에도 stable, mutable_, stability_counter_type, arity, store_parent_pointer 라는 설정이 있다. 50 | 51 | -------------------------------------------------------------------------------- /boost_container/index.md: -------------------------------------------------------------------------------- 1 | # boost.container 2 | 1.48 버전에서 새로 추가. 3 | STL 호환 컨테이너 라이브러리 4 | C++03 컴파일러에서 C++11의 기능을 사용할 수 있음 5 | - Move semantics 6 | - placement insertion 7 | - recursive containers. 8 | 9 | ![Boost.Container](resource/008.PNG "Boost.Container") 10 | 11 | 12 | - [Heap](heap.md) 13 | - [static_vector](static_vector.md) 14 | - [stable_vector](stable_vector.md) 15 | - [flat_(multi)map/set](flat_map-set.md) 16 | - [독자적인 allocator 사용하기](allocator.md) 17 | 18 | 19 | ## tool 20 | - [CPPDebuggerVisualizers](https://github.com/KindDragon/CPPDebuggerVisualizers) 21 | 22 | 23 | 24 | ## 참고 25 | - [Intrusive data structure 소개](http://www.slideshare.net/ohyecloudy/intrusive-data-structure) -------------------------------------------------------------------------------- /boost_container/resource/001.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/resource/001.PNG -------------------------------------------------------------------------------- /boost_container/resource/002.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/resource/002.PNG -------------------------------------------------------------------------------- /boost_container/resource/003.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/resource/003.PNG -------------------------------------------------------------------------------- /boost_container/resource/004.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/resource/004.PNG -------------------------------------------------------------------------------- /boost_container/resource/005.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/resource/005.PNG -------------------------------------------------------------------------------- /boost_container/resource/006.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/resource/006.PNG -------------------------------------------------------------------------------- /boost_container/resource/007.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/resource/007.PNG -------------------------------------------------------------------------------- /boost_container/resource/008.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/resource/008.PNG -------------------------------------------------------------------------------- /boost_container/resource/009.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/resource/009.PNG -------------------------------------------------------------------------------- /boost_container/resource/010.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/resource/010.PNG -------------------------------------------------------------------------------- /boost_container/resource/011.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/resource/011.PNG -------------------------------------------------------------------------------- /boost_container/resource/012.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/resource/012.PNG -------------------------------------------------------------------------------- /boost_container/resource/013.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/resource/013.PNG -------------------------------------------------------------------------------- /boost_container/resource/014.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/boost_container/resource/014.PNG -------------------------------------------------------------------------------- /boost_container/stable_vector.md: -------------------------------------------------------------------------------- 1 | ## stable_vector 2 | - 이름 그대로 안정된 vector. 3 | - std::vector는 저장된 요소의 연속성을 보장하지만 반복자가 무효화 될 수 있다. (이 문제를 해결하려면 std::list 사용) 4 | - stable_vector는 요소의 연속성 확보 보다 요소를 가리키는 포인터를 연속으로 보존. 5 | - 리스트와 비슷하지만 임의접근이 가능하다. 6 | - 삽입, 삭제가 발생하여도 저장된 요소가 이동하지 않는다. 7 | - 요소 중에 새로운 요소를 추가하여도 그 이후의 모든 요소를 이동하지 않고 포인터를 복사하는 것으로 완료. 8 | 9 | 10 | ### 예제 코드 11 | ```C++ 12 | std::vector v; 13 | 14 | v.push_back(1); 15 | auto const it = v.begin(); 16 | 17 | for (int i = 2; i < 10; ++i) 18 | v.push_back(i); 19 | 20 | // ??? 21 | std::cout << *it; 22 | ``` 23 | 24 | ```C++ 25 | // http://codezine.jp/article/detail/8259 26 | 27 | void memory_usage() { 28 | cout << "\n=== memory_usage\n"; 29 | { 30 | std::vector v; 31 | for ( int i = 0; i < 5; ++i ) { 32 | v.emplace_back(i); 33 | } 34 | cout << "\n--- std::vector : before\n"; 35 | for ( const int& val : v ) { 36 | cout << setw(4) << val << " @ " << static_cast(&val) << endl; 37 | } 38 | 39 | cout << "\n--- std::vector : after\n"; 40 | v.erase(begin(v)+2); 41 | for ( const int& val : v ) { 42 | cout << setw(4) << val << " @ " << static_cast(&val) << endl; 43 | } 44 | 45 | cout << endl; 46 | } 47 | 48 | ``` 49 | ![Boost.Container](resource/009.PNG "Boost.Container") 50 | 메모리가 연속적으로 할당 되지 않는다. 51 | 52 | ```C++ 53 | //http://codezine.jp/article/detail/8259 54 | 55 | void memory_detail() { 56 | cout << "\n=== boost::container::stable_vector\n--- 3 insertions\n"; 57 | boost::container::stable_vector> vv; 58 | for ( int i = 0; i < 3; ++i ) { 59 | vv.emplace_back(i); 60 | } 61 | for ( int item : vv) { 62 | cout << item << ' '; 63 | } 64 | cout << endl; 65 | } 66 | ``` 67 | ![Boost.Container](resource/010.PNG "Boost.Container") 68 |

69 | 포인터 배열의 각 요소에 node가 매달려서, 각 노드는 반대 방향 포인터를 가지고 있다. 70 | 그래서 stable_vecto의 반복자는 각 node를 가리킨다. 그래서 어떤 반복자에 대해서, 71 | node에서 node*열에 오르고 72 | 거기서 n개 이동한다(포인터에 n을 더한다) 73 | node에 내린다 74 | 라는 조작으로 n개 옆으로 이동할 수 있다. 75 | 이런 편법으로 랜덤 접근을 구현하고 있어서 예를 들면 std::sort()로 정렬할 수 있다. 76 | 또 이 구조에 의해 어떤 요소를 가리키는 반복자는(그 요소를 삭제하지 않는 한) 요소의 삽입/삭제에 따른 무효가 되는 일이 없다. 77 | ![Boost.Container](resource/011.PNG "Boost.Container") 78 | 79 | 80 | ### 예제 프로그램 81 | - stable_vector_01 82 | - stable_vector_02 83 | 84 | 85 | ### 장단점 86 | - 요소의 안정성을 중시해서 각종 성능에서는 vector, list에 비해 다소 떨어진다. 87 | - 요소 접근을 위해 1회 불필요한 간접 참조를 해야하므로 vector 보다 느리다. 88 | - 요소들을 연속해서 보존하고 있다는 것을 보증할 수 없으므로 캐시 효율도 나쁘다. 89 | - vector 보다 많은 메모리를 필요로 한다. 90 | (c + 1)p + (n + 1)(e + p) 91 | c=capacity(), p=sizeof(T*), n=size(), e=sizeof(T) 92 | vector는 c×e 93 | - 그러나 때로는 vector 보다 더 적은 메모리를 사용하기도 한다. 94 | c >> n 일 때는 요소를 저장하기 위한 영역이 vector은 cXe 이지만 stable_vector는 nXe만 필요로 한다. 95 | - 이름과 다르게 vector의 대체보다는 list의 대체에 더 가깝다. 96 | 97 | 98 | -------------------------------------------------------------------------------- /boost_container/static_vector.md: -------------------------------------------------------------------------------- 1 | ## static_vector 2 | - 1.54에 추가 되었다. 3 | - std::vector와 std::array 양쪽의 특성을 모두 가진 하이브리드 컨테이너. 4 | - 정적인 영역을 사용하는 가변 길이 배열. static_vector 에서 N 이하의 가변 길이 배열이다. 5 | - 고정 capacity를 두 번째 템플릿 인수로 지정하면 그 사이즈가 정적으로 영역을 확보한다. 6 | - 정해진 capacity를 넘지 않도록 추가/삭제를 해야 한다. 7 | - 정해진 capacity를 넘지 않도록 추가/삭제를 해야 한다. 범위를 넘으면 예외 발생 8 | - 임의접근 가능. 9 | - 제일 뒤 삽입/삭제는 정수 시간 10 | - 선두나 중간 삽입/삭제는 선형 시간 11 | - 최대 요소 수가 다른 static_vector과 static_vector 간에 복사를 할 수 있지만 target(좌변)의 capacity()가 source(우변) size() 보다 작으면 std:bad_alloc 예외 발생 12 | - 할당자를 가지지 않는 것만 빼고는 std::vector와 같다. 13 | 14 | 15 | ### 예제 코드 16 | ```C++ 17 | // http://faithandbrave.hateblo.jp/entry/20130712/1373614497 18 | 19 | #include 20 | #include 21 | 22 | int main() 23 | { 24 | boost::container::static_vector v; 25 | 26 | // 요소 추가 27 | v.push_back(3); 28 | v.push_back(1); 29 | v.push_back(4); 30 | 31 | // 모든 요소 출력 32 | for (int x : v) { 33 | std::cout << x << std::endl; 34 | } 35 | 36 | // capacity를 넘는 요소를 추가하려고 하면 bad_alloc 예외가 던져진다 37 | // v.push_back(5); 38 | } 39 | ``` 40 |
41 | 3
42 | 1
43 | 4
44 | 
45 | 46 | 47 | ```C++ 48 | // http://codezine.jp/article/detail/8259 49 | #include 50 | #include 51 | 52 | using namespace std; 53 | 54 | int main() { 55 | const int N = 10; 56 | 57 | cout << "static_vector\t: " << sizeof(boost::container::static_vector) << endl; 58 | cout << "static_vector\t: " << sizeof(boost::container::static_vector) << endl; 59 | cout << "static_vector\t: " << sizeof(boost::container::static_vector) << endl; 60 | cout << endl; 61 | 62 | boost::container::static_vector sv { -3, -2, -1 }; 63 | 64 | try { 65 | for ( int i = 0; i < N; ++i ) { 66 | sv.emplace_back(i); 67 | } 68 | } catch ( std::exception& ex) { 69 | cout << ex.what() << endl; 70 | cout << "CAN'T INSERT ITEMS ANY MORE!\n" << endl; 71 | } 72 | 73 | for ( int item : sv ) { 74 | cout << item << endl; 75 | } 76 | 77 | } 78 | ``` 79 | 80 | 81 | ### 예제 프로그램 82 | - static_vector_01 83 | - static_vector_02 84 | 85 | -------------------------------------------------------------------------------- /circular_buffer.md: -------------------------------------------------------------------------------- 1 | ## circular_buffer 2 | ![circular_buffer](resource/006.PNG "circular_buffer") 3 | 4 | - 순환 버퍼 라이브러리. 5 | - FIFO 알고리즘 사용 가능. 6 | - 고정 크기의 메모리 영역을 선 확보 후 그 영역을 링 형태로 사용. 7 | - 할당한 크기 이내에서는 push_back, pop_back, pop_front는 O(1). 8 | - 임의 접근 가능. 9 | - 할당 한 크기를 넘으면 반대 측 끝을 재 사용. 10 | 11 | ![circular_buffer](resource/007.PNG "circular_buffer") 12 | 13 | ### 에제 14 | - circular_buffer_01 15 | - circular_buffer_02 16 | - circular_buffer_03 17 | - circular_buffer_04 18 | - circular_buffer_05 19 | 20 | 21 | -------------------------------------------------------------------------------- /date_time.md: -------------------------------------------------------------------------------- 1 | # 개요 2 | - 날짜 계산 라이브러리. 3 | - Gregorial을 사용한다. 4 | 5 | 6 | # 사용 예 7 | 8 | ## 월의 마지막 날 9 | ``` 10 | #include 11 | #include 12 | 13 | int main() 14 | { 15 | using namespace boost::gregorian; 16 | 17 | const int day = gregorian_calendar::end_of_month_day(2011, 2); 18 | std::cout << day << std::endl; 19 | } 20 | // 출처: https://sites.google.com/site/boostjp/tips/date_time 21 | ``` 22 | 23 | ## 날짜 더하기/빼기 24 | - 년의 가감산에는 years 타입, 월의 가감산에는 months 타입, 날의 가감산에는 days 타입을 사용한다. 25 | 26 | ``` 27 | #include 28 | #include 29 | 30 | using namespace boost::gregorian; 31 | 32 | int main() 33 | { 34 | const date d1(2011, Apr, 1); 35 | const date d2 = d1 + months(1) - days(1); 36 | 37 | std::cout << to_simple_string(d2) << std::endl; 38 | } 39 | //출처: https://sites.google.com/site/boostjp/tips/date_time 40 | ``` 41 | 42 | ## UTL <-> LOCAL 43 | ``` 44 | #include 45 | 46 | #include 47 | #include 48 | #include 49 | 50 | int main(const int argc, const char * const argv[]) 51 | { 52 | using namespace boost; 53 | 54 | posix_time::ptime now = posix_time::second_clock::universal_time(); 55 | 56 | // utc to local 1 57 | date_time::c_local_adjustor adj1; 58 | posix_time::ptime t1 = adj1.utc_to_local(now); 59 | 60 | // utc to local 2 61 | date_time::local_adjustor adj2; 62 | posix_time::ptime t2 = adj2.utc_to_local(now); 63 | 64 | // local to utc 65 | posix_time::ptime t3 = adj2.local_to_utc(t2); 66 | 67 | // out 68 | std::cout << now << std::endl; 69 | std::cout << t1 << std::endl; 70 | std::cout << t2 << std::endl; 71 | std::cout << t3 << std::endl; 72 | 73 | return 0; 74 | } 75 | ``` 76 | -------------------------------------------------------------------------------- /dll.md: -------------------------------------------------------------------------------- 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 |
15 | 16 | plugin_type.hxx: 17 | ``` 18 | #pragma once 19 | 20 | #include 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 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 59 | #include 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 90 | 91 | #include 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 | -------------------------------------------------------------------------------- /graph.md: -------------------------------------------------------------------------------- 1 | # boost::graph 2 | boost::graphのお勉強 http://qiita.com/kktk-KO/items/6c53e1c550cae441c969 3 | boostのグラフ別,動作の違い http://folioscope.hatenablog.jp/entry/2012/10/31/224238 4 | Boost.GraphでJR全線乗り尽くしプランを立てる - プログラミング生放送 http://www.slideshare.net/maraigue/chinese-postman 5 | 6 | http://boost.cppll.jp/HEAD/libs/graph/doc/graph_theory_review.html 7 | http://d.hatena.ne.jp/faith_and_brave/20100413/1271129607 8 | http://d.hatena.ne.jp/faith_and_brave/20100415/1271315024 9 | http://d.hatena.ne.jp/faith_and_brave/20100416/1271388752 10 | 11 | Boost.Graph 到達可能かどうかをチェックする http://d.hatena.ne.jp/faith_and_brave/20111011/1318317668 12 | Boost.Graph 最短?路の長さ(weight)を計算する http://d.hatena.ne.jp/faith_and_brave/20111012/1318407981 13 | Boost.Graph filtered_graph http://d.hatena.ne.jp/faith_and_brave/20111014/1318572553 14 | Boost.Graph is_reachableAdd Star http://d.hatena.ne.jp/faith_and_brave/20111017/1318837488 15 | Boost.Graph is_adjacent http://d.hatena.ne.jp/faith_and_brave/20111018/1318915464 16 | Boost.Graph vectorを有向グラフとして使用する http://d.hatena.ne.jp/faith_and_brave/20111019/1319002566 17 | Boost.Graph 頂点と辺の数を取得 http://d.hatena.ne.jp/faith_and_brave/20111031/1320039384 18 | Boost.Graph PredecessorMap http://d.hatena.ne.jp/faith_and_brave/20111101/1320125923 19 | Boost.Graph DistanceMap http://d.hatena.ne.jp/faith_and_brave/20111102/1320211726 20 | Boost.Graph 最短経路を計算する過程を取得 http://d.hatena.ne.jp/faith_and_brave/20111115/1321338504 21 | Boost.Graph 2つのグラフが同型かを調べる http://d.hatena.ne.jp/faith_and_brave/20120612/1339489283 22 | Boost.Graph トポロジカルソート http://d.hatena.ne.jp/faith_and_brave/20120613/1339577486 23 | グラフ理論 Welsh-Powellの頂点彩色アルゴリズムを実装してみた http://d.hatena.ne.jp/devm33/20120616/1339811432 24 | Boost.Graph Bundleプロパティ http://d.hatena.ne.jp/faith_and_brave/20120619/1340093038 25 | Boost.Graph 最短?純路 http://d.hatena.ne.jp/faith_and_brave/20120626/1340689362 26 | Boost.Graph 最小全域木を作る http://d.hatena.ne.jp/faith_and_brave/20120627/1340783683 27 | Boost.Graph 一筆書き http://d.hatena.ne.jp/faith_and_brave/20120628/1340866757 28 | Boost.Graph 複?ソ?スの幅優先探索 http://d.hatena.ne.jp/faith_and_brave/20121120/1353405062 29 | Boost.Graph スモールワールドを作る http://d.hatena.ne.jp/faith_and_brave/20121207/1354866489 30 | Boost.Graph 全頂点間最短距離を求め http://d.hatena.ne.jp/faith_and_brave/20121212/1355295002 31 | astar_shortest_path.cpp https://gist.github.com/faithandbrave/7331277 32 | Boost.Graphでの最短経路探索 http://goyoki.hatenablog.com/entry/2014/03/02/023758 33 | Boost.Graph Graphvizの情報をユーザー定義型に読み込む http://faithandbrave.hateblo.jp/entry/2015/04/13/231836 34 | 最短経路探索 (Boost Graph Library 利用でダイクストラ法) https://qiita.com/kkdd/items/73fdc783799a71f19d15 -------------------------------------------------------------------------------- /in_place.md: -------------------------------------------------------------------------------- 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 11 | #include 12 | #include 13 | #include 14 | 15 | template 16 | class hoge 17 | { 18 | public: 19 | 20 | //T 타입 분의 메모리를 확보한다 21 | hoge() : buffer_(reinterpret_cast(new char[sizeof(T)])) 22 | { 23 | } 24 | 25 | //메모리 해제 26 | ~hoge() 27 | { 28 | delete buffer_; 29 | } 30 | 31 | //확보한 메모리에 오브젝트를 확보한다 32 | template 33 | void construct(const InPlace& p) 34 | { 35 | p.template apply(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 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 |
89 | (100, 200)
90 | (300, 400)
91 | 
92 | -------------------------------------------------------------------------------- /msm.md: -------------------------------------------------------------------------------- 1 | # Boost::msm 2 | Boost.Msm 사용 방법 http://www.slideshare.net/redboltz/boost-sapporomsm-pre 3 | 4 | https://sites.google.com/site/boostjp/tips/finite_state_machine 5 | http://d.hatena.ne.jp/osyo-manga/20100917/1284716191 6 | http://d.hatena.ne.jp/kura-replace/20110514/1305385110 7 | http://d.hatena.ne.jp/redboltz/20110625/1308997694 8 | http://d.hatena.ne.jp/redboltz/20110626/1309046959 9 | http://d.hatena.ne.jp/redboltz/20110626/1309074006 10 | 11 | if/else分岐 http://d.hatena.ne.jp/redboltz/20110722/1311312541 12 | 13 | Boost.Msmがサポ?トしないUML表記とその??法 http://d.hatena.ne.jp/redboltz/20110722/1311297996 14 | 15 | http://d.hatena.ne.jp/redboltz/20110726/1311682730 16 | 17 | 開始疑似?態と?行?態 http://d.hatena.ne.jp/redboltz/20110803/1312336449 18 | 19 | entry point疑似?態の?? http://d.hatena.ne.jp/redboltz/20110803/1312359024 20 | 21 | 状態マシンの内部で別のイベントを発生させる http://d.hatena.ne.jp/redboltz/20110813/1313244419 22 | 23 | イベントの延期(defer) http://d.hatena.ne.jp/redboltz/20110815/1313388757 24 | 25 | 遷移テ?ブルの評?順序を上から下にする http://d.hatena.ne.jp/redboltz/20110818/1313655344 26 | 27 | entry pseudo stateのリージョンIDの省略 http://d.hatena.ne.jp/redboltz/20120306/1331030665 28 | 29 | entry point疑似?態の??の制約とその??策 http://d.hatena.ne.jp/redboltz/20120603/1338706853 30 | 31 | -------------------------------------------------------------------------------- /multi_index.md: -------------------------------------------------------------------------------- 1 | # multi_index 2 | 3 | ![multi_index](resource/001.PNG "multi_index") 4 | 5 |

6 | 7 | ![multi_index](resource/002.PNG "multi_index") 8 | 9 | ![multi_index](resource/003.PNG "multi_index") 10 | 11 | ![multi_index](resource/004.PNG "multi_index") 12 | 13 | ![multi_index](resource/005.PNG "multi_index") 14 | 15 | 16 | 17 | # Key 종류 18 | - lidentity 19 | - lmember 20 | - lconst_mem_fun 21 | - lmem_fun 22 | - lglobal_fun 23 | - lcomposite_key 24 | 25 | 26 | 27 | ## 예제 코드 28 | - multi_index_01. std::list + std::multiset 29 | - multi_index_02. std::vector + std::multiset 30 | - multi_index_03. 가독성 Up 31 | - multi_index_04. 유저 정의 타입 사용 32 | - multi_index_05. 유저 정의 타입 + 멤버 함수 키 + 합성 키 + bound 33 | - multi_index_06. 유저 정의 타입 + std::multiset + std::map 34 | - multi_index_07. replace 35 | - multi_index_08. modify 36 | - multi_index_09. member_offset_ 37 | 38 | 39 | 40 | ## 참고 41 | - [boost::multi_index 간단 사용법](http://egloos.zum.com/humnya/v/2905407) 42 | - [Boost.multi_index 사용하기](https://www.slideshare.net/OnGameServer/sdc-3rd) 43 | - [Boost - Multi Index Map](http://sysroad.dlinkddns.com/phame/post/view/30/boost_-_multi_index_map/) 44 | - [boost::multi_index](http://neive.tistory.com/212) 45 | 46 | -------------------------------------------------------------------------------- /numeric-interval.md: -------------------------------------------------------------------------------- 1 | # boost::numeric::interval 2 | 3 | ## 개요: 구간 연산 라이브러리는 4 | 구간 연산 라이브러리는 말 그대로 수학의 "구간"을 다루기 위한 라이브러리이다. 5 | Boost 구간 연산 라이브러리는 `#include ` 를 포함하는 것만으로 간단하게 사용할 수 있다. 6 | ``` 7 | #include 8 | #include 9 | #include 10 | 11 | int main () { 12 | boost::numeric::interval a(-1, 2); 13 | std::cout << a << std::endl; 14 | return 0; 15 | } 16 | ``` 17 | 18 |
  
 19 | $ g ++ hello-interval.cpp -o hello-interval
 20 | $ ./hello-interval
 21 | [-1,2]
 22 | 
23 | 24 | 이처럼 구간의 기반이 되는 T 타입을 템플릿 인수에 구간 타입 boost::numeric::interval을 사용할 수 있다. 25 | 사실, 이 구간 타입 interval과 2 개의 템플릿 인수를 취하도록 선언 되어 있고, Policies에 다양하게 지정하여 세세한 행동을 바꿀 수 있다. 26 | 기본값은 기본 정책이 사용되고, 보통은 기본만으로 충분하다. 27 | 28 | Remark. 구간 연산 라이브러리는 어떤 계산기 · 어떤 컴파일러에 대해서도 "정확한 계산"을 지원하고 있는 것은 아니다. 사용하고 있는 컴퓨터 환경에서 구간 연산 라이브러리를 올바르게 사용할 수 있는지 여부는 공식 문서 등으로 확인 해야 한다. 29 | 30 | 31 | 32 | ## 사칙 연산과 기본 함수 33 | 34 | ### 구간끼리의 사칙 연산 35 | 부동 소수점 오차까지 고려하면서 구간의 수 모두에 대한 연산 결과를 모두 포함하도록 구간을 계산하여 반환한다. 36 | 37 | test-interval-arith-IRxIR.cpp: 38 | ``` 39 | #include 40 | #include 41 | #include 42 | 43 | int main () { 44 | typedef double R; 45 | typedef boost::numeric::interval IR; 46 | using std::cout; 47 | using std::endl; 48 | const IR a(1.0, 2.0); 49 | const IR b(3.0, 4.0); 50 | cout << "a = " << a << endl; 51 | cout << "b = " << b << endl; 52 | cout << "a + b = " << a + b << endl; 53 | cout << "a - b = " << a - b << endl; 54 | cout << "a * b = " << a * b << endl; 55 | cout << "a / b = " << a / b << endl; 56 | return 0; 57 | } 58 | ``` 59 |
 60 | a = [1,2]
 61 | b = [3,4]
 62 | a + b = [4,6]
 63 | a - b = [-3,-1]
 64 | a * b = [3,8]
 65 | a / b = [0.25,0.666667]
 66 | 
67 | [Wandbox](https://wandbox.org/permlink/8qtcQb4XXNOkLEzw ) 68 | 69 | 또한 좌변 값에 사칙 연산을 직접 수행하는 연산자 +=, -=, *=, /= 도 있다. 70 | 71 | Remark. 일반적으로 구간의 이항 연산 +과 -는 서로 반대 연산의 관계는 되지 않는다. 예를 들어, 원래 오차가 없이 + 와 - 가 서로 반대 연산의 관계에 있는 int를 기반으로 하는 구간 타입 interval의 경우를 생각해도 [1, 2] - [1, 2]는 [0, 0]는 안된다. * 와 / 도 마찬가지이다. 따라서, 일반적으로는 구간 연산의 반복으로 구간은 점점 커져간다. 부동 소수점 타입의 경우에는 구간 타입을 생각하여 원래 역 연산 관계에 없었던 사칙 연산이 가지는 '오차'라는 성격이 더 두드러 졌다고도 할 수 있다. 72 | 73 | 74 | ### 구간 수의 사칙 연산 75 | 사칙 연산의 인수의 한쪽은 베이스 타입 T의 값으로 제공 할 수 있다. 이러한 경우 먼저 인수를 interval로 변환하여 연산을 수행한 것과 같은 결과가 된다(이것은 이후 나오는 다른 함수에 대해서도 대략 마찬가지이다). 76 | Remark. interval는 하단과 상단의 2 인자를 취하는 생성자 이외에도 베이스 타입 T의 값 x를 취하고, 일점 구간[x, x]를 만드는 1 인자 생성자가 있다. 77 | 78 | test-interval-arith-IRxR.cpp: 79 | ``` 80 | #include 81 | #include 82 | #include 83 | 84 | int main () { 85 | typedef double R; 86 | typedef boost::numeric::interval IR; 87 | using std::cout; 88 | using std::endl; 89 | const IR a(1.0, 2.0); 90 | const R b = 3.0; 91 | cout << "a = " << a << endl; 92 | cout << "b = " << b << endl; 93 | cout << "a + b = " << a + b << endl; 94 | cout << "a - b = " << a - b << endl; 95 | cout << "a * b = " << a * b << endl; 96 | cout << "a / b = " << a / b << endl; 97 | return 0; 98 | } 99 | ``` 100 | 101 | 102 | ### 숫자끼리의 사칙 연산 103 | 두 인수를 베이스 타입으로 주고 사칙하려면 어떻게할까? 이런 때에는 boost::numeric::interval_lib 에 정의된 함수 add, sub, mul, div을 사용한다. 이들은 베이스 타입 T 값을 2개의 인수로 잡고, 사칙 연산 절단 · 절상을 각각 하단 · 상단으로 하는 interval 타입의 구간을 계산하여 반환한다. 104 | 105 | test-interval-arith-RxR.cpp: 106 | ``` 107 | #include 108 | #include 109 | #include 110 | 111 | int main () { 112 | typedef double R; 113 | typedef boost::numeric::interval IR; 114 | using std::cout; 115 | using std::endl; 116 | const R a = 1.7; 117 | const R b = 3.3; 118 | cout << "a = " << a << endl; 119 | cout << "b = " << b << endl; 120 | { 121 | using namespace boost::numeric::interval_lib; 122 | cout << "a + b = " << add(a, b) << "w(" << width(add(a, b)) << ")" << endl; 123 | cout << "a - b = " << sub(a, b) << "w(" << width(sub(a, b)) << ")" << endl; 124 | cout << "a * b = " << mul(a, b) << "w(" << width(mul(a, b)) << ")" << endl; 125 | cout << "a / b = " << div(a, b) << "w(" << width(div(a, b)) << ")" << endl; 126 | } 127 | return 0; 128 | } 129 | ``` 130 | 131 | 위의 프로그램에서 제대로 구간 연산이 이루어지면 아래와 같은 결과를 얻을 수 있다. 여기서 width는 구간의 폭, 즉 상단과 하단의 차이를 계산하는 함수이다. 부동 소수점 연산에 의해 부동 소수점 오차가 0이 아닌 구간 폭으로 나타나고 있음을 간파 할 수 있다. 132 | 133 | output-for-test-interval-arith-RxR.txt 134 |
135 | a = 1.7
136 | b = 3.3
137 | a + b = [5,5] w (8.88178e-16)
138 | a - b = [-1.6, -1.6] w (0)
139 | a * b = [5.61,5.61] w (8.88178e-16)
140 | a / b = [0.515152,0.515152] w (1.11022e-16)
141 | 
142 | 143 | Remark. 물론 1 인자 생성자를 사용하여 IR(1) / IR(9) 등과 써도 비슷한 것을 얻을 수 있지만 이러한한데 구간끼리의 연산이라고 같은 계산이 추가로 발생 해 버리는 순간 div(1, 9)이 약간 효율이 좋다. 144 | 145 | 146 | ### 하단 · 상단 · 중간 · norm 147 | 구간의 폭을 계산하는 함수 width처럼 interval 타입으로 주어진 구간에 대해서 하등의 베이스 타입 T 의 값을 반환하는 함수로 lower, upper, median, norm 가 있다. 처음 세개는 문자적인 의미로 각 구간의 하단 · 상단 · 중간 점을 반환하는 함수이다. norm이 구간이 포함 숫자의 최대 절대 값을 반환한다. 148 | 149 | 150 | 151 | 152 | ## 출처: 153 | - https://qiita.com/t_uda/items/7712671389e016d24df6 154 | - https://qiita.com/t_uda/items/e4f554b8af864b638a6d 155 | - https://qiita.com/t_uda/items/abcf31a7b1787604a4f4 156 | - https://qiita.com/t_uda/items/e08ca64b318917e6d4ab 157 | -------------------------------------------------------------------------------- /pool.md: -------------------------------------------------------------------------------- 1 | ## Pool 2 | - 적당한 메모리를 처음부터 확보하고, 그기에서 적절한 메모리를 할당 받는다. 3 | - 고속으로 메모리를 할당할 수 있다. 4 | - 그러나 사용할 수 있는 곳이 한정되어 있다. 5 | - 대량의 작은 오브젝트를 관리해야 하는 경우에 아주 좋다. 6 | - 게임의 오브젝트 관리나 메모리 제어가 아주 중요한 곳에서 주로 사용한다. 7 | - 메모리를 확보한 순서로 메모리 해제를 하면 object_pool 이 boost::pool 보다 느리다. 8 | 9 | 10 | 11 | ## 오브젝트와 싱글톤 12 | - 적당한 메모리를 처음부터 확보하고, 그기에서 적절한 메모리를 할당 받는다. 13 | - 고속으로 메모리를 할당할 수 있다. 14 | - 그러나 사용할 수 있는 곳이 한정되어 있다. 15 | - 대량의 작은 오브젝트를 관리해야 하는 경우에 아주 좋다. 16 | - 게임의 오브젝트 관리나 메모리 제어가 아주 중요한 곳에서 주로 사용한다. 17 | 18 | 19 | 20 | ## 간단 사용 법 21 | 22 | ### 오브젝트 풀 23 | 24 | ``` 25 | struct Abc 26 | { 27 | Abc() { static int no=0; cout << "Abc() :" << (m_no=++no) << endl; } 28 | ~Abc() { cout << "~Abc():" << m_no << endl; } 29 | int m_no; 30 | }; 31 | 32 | boost::object_pool p; 33 | Abc* x = p.construct(); 34 | Abc* y = p.construct(); 35 | Abc* z = p.construct(); 36 | p.destroy(y);// 명시적으로 파괴자 호출 37 | ``` 38 | 39 | 40 | ### 싱글톤 풀 41 | 42 | ``` 43 | // sizeof(int) 바이트 전용 할당자 44 | boost::pool<> p( sizeof(int) ); 45 | int* x = (int*)p.malloc(); 46 | int* y = (int*)p.malloc(); 47 | int* z = (int*)p.malloc(); 48 | *x = 10; 49 | p.free(z); // 명시적으로 free 50 | ``` 51 | 52 | 53 | 54 | ## 참고 55 | - [boostのobject_poolをスマートポインタで利用する](http://d.hatena.ne.jp/ytakano/20100317/1268778286 ) 56 | -------------------------------------------------------------------------------- /predef.md: -------------------------------------------------------------------------------- 1 | ## 개요 2 | - Pre_defined Compiler Macros 프로젝트에서 모아 놓은 매크로로 C++ 컴파일 환경이나 타겟 환경(OS) 정보를 얻을 수 있다. 3 | - Boost 1.55 에서 추가 4 | 5 | 6 | 7 | ## OS, 컴파일러, 비주얼스튜디오 버전 8 | 9 | ``` 10 | // 출처: http://d.hatena.ne.jp/osyo-manga/20131213/1386933884 11 | #include 12 | #include 13 | #include 14 | 15 | int main() 16 | { 17 | std::cout << BOOST_COMPILER << std::endl; 18 | 19 | #if BOOST_OS_WINDOWS 20 | std::cout << "OS is Windows." << std::endl; 21 | #else 22 | std::cout << "OS is not Windows." << std::endl; 23 | #endif 24 | 25 | #if BOOST_COMP_CLANG 26 | std::cout << "Compiler is Clang." << std::endl; 27 | #elif BOOST_COMP_MSVC 28 | std::cout << "Compiler is MSVC." << std::endl; 29 | #else 30 | std::cout << "Compiler is unknow." << std::endl; 31 | #endif 32 | 33 | 34 | #if BOOST_COMP_MSVC && BOOST_COMP_MSVC >= BOOST_VERSION_NUMBER(12, 0, 0) 35 | std::cout << "VC 12" << std::endl; 36 | #elif BOOST_COMP_MSVC && BOOST_COMP_MSVC >= BOOST_VERSION_NUMBER(13, 0, 0) 37 | std::cout << "VC 13" << std::endl; 38 | #endif 39 | 40 | return 0; 41 | } 42 | ``` 43 | -------------------------------------------------------------------------------- /program_options.md: -------------------------------------------------------------------------------- 1 | # Program Options 2 | [공식 문서](https://www.boost.org/doc/libs/1_73_0/doc/html/program_options.html ) 3 | 4 | ## 명령 줄 인수를 boost :: program_options에 저장 5 | [출처](http://tips.hecomi.com/entry/20110210/1297353366 ) 6 | 7 | `boost::program_options`을 사용하면 명령어 라인 인수를 쉽게 분석 할 수 있다. 8 | 9 | ### 사용법 10 | 한 가지 방법을 정리해 보았다. 11 | ``` 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace std; 19 | using namespace boost::program_options; 20 | 21 | int main(int argc, char* argv[]) 22 | { 23 | // 옵션 정의를 한다 24 | // 뒤에서 합칠 수 있다. 25 | options_description options1("옵션 그룹 1"); 26 | options_description options2("옵션 그룹 2"); 27 | options_description options3("옵션 그룹 3"); 28 | options_description options4("옵션 그룹 4"); 29 | 30 | // 옵션은 add_options() 이후에 operator()를 연결시켜서 추가 31 | // 「,」의 앞에 정식 이름, 뒤에 줄임 이름을 적는다(생략 가능) 32 | options1.add_options() 33 | ("option1", "옵션 1") 34 | ("option2,b", "옵션 2") 35 | ; 36 | 37 | // option=*** 으로 받는 값의 타입을 설정할 수 있다. 38 | // 또 default_value 로 기본 값도 설정 가능 39 | options2.add_options() 40 | ("option3,c", value(), "옵션3") 41 | ("option4,d", value(), "옵션4") 42 | ("option5,e", value()->default_value(10), "옵션5") 43 | ; 44 | 45 | // option=*** 의 값을 받는 변수를 지정할 수도 있다 46 | int option6; 47 | string option7; 48 | options3.add_options() 49 | ("option6,f", value(&option6), "옵션6") 50 | ("option7,g", value(&option7), "옵션7") 51 | ; 52 | 53 | // 같은 옵션을 복수 사용하여 저장할 수도 있다 54 | options4.add_options() 55 | ("option8", value >(), "옵션8") 56 | ; 57 | 58 | // 옵션 정의를 모을 수 있다 59 | options1.add(options2).add(options3); 60 | 61 | // 옵션 값을 읽는 변수 62 | variables_map values; 63 | 64 | // 다양한 예외를 잡을 수 있다(예는 catch 블럭 내에 기술한다) 65 | try { 66 | // parse_command_line 에서 명령어 라인 인수를 parse 하고, 67 | // 이 결과를 store에서 variable_maps 에 저장한다 68 | store(parse_command_line(argc, argv, options1), values); 69 | 70 | // 명령어 라인 인수뿐만 아닌 외부 파일에서도 옵션을 읽을 수 있다 71 | // 이 때는 parse_config_file을 사용하여 parse 한다 72 | ifstream ifs("config.txt"); 73 | store(parse_config_file(ifs, options4), values); 74 | 75 | // notify를 호출하여 values에 값을 저장한다 76 | notify(values); 77 | 78 | // 옵션 유무는 count로 조사한다 79 | if (!values.count("option1") && !values.count("option2")) { 80 | // options_description는 표준 출력에 던질 수 있다 81 | cout << options1 << endl; 82 | cout << options4 << endl; 83 | } 84 | if (values.count("option1")) { 85 | cout << "option1 이 지정 되었다" << endl; 86 | } 87 | if (values.count("option2")) { 88 | cout << "option2 이 지정 되었다" << endl; 89 | } 90 | 91 | // as<타입 이름>() 으로 값을 얻을 수 있다 92 | cout << "option3: " << values["option3"].as() << endl; 93 | cout << "option4: " << values["option4"].as() << endl; 94 | cout << "option5: " << values["option5"].as() << endl; 95 | 96 | cout << "option6: " << option6 << endl; 97 | cout << "option7: " << option7 << endl; 98 | 99 | // 복수의 데이터를 받은 것도 사용 가능 100 | cout << "option8: "; 101 | vector option8( values["option8"].as >() ); 102 | for (vector::iterator it = option8.begin(); it != option8.end(); ++it) { 103 | cout << *it << " "; 104 | } 105 | cout << endl; 106 | 107 | } catch (exception &e) { 108 | // 저장 되지 않은 것을 values["***"] 를 호출하면 109 | // boost::bad_any_cast: failed conversion using boost::any_cast 110 | // 가 표시된다. 111 | // 정의 되지 않은 옵션 --*** 을 호출하면 112 | // unknown option *** 113 | // 가 표시된다 114 | cout << e.what() << endl; 115 | } 116 | 117 | return 0; 118 | } 119 | ``` 120 | 121 | ### 결과 122 |
123 | 명령 줄 인수를 주지 않는 경우
124 | 옵션 그룹 1 :
125 |   --option1 옵션 1
126 |   -b [--option2 옵션 2
127 | 
128 | 옵션 그룹 2 :
129 |   -c [--option3] arg 옵션 3
130 |   -d [--option4] arg 옵션 4
131 |   -e [--option5] arg (= 10) 옵션 5
132 | 
133 | 옵션 군 3 :
134 |   -f [--option6] arg 옵션 6
135 |   -g [--option7] arg 옵션 7
136 | 
137 | 옵션 그룹 4 :
138 |   --option8 arg 옵션 8
139 | 
140 | 141 | 142 | ### 명령 라인 인수를 준 경우 143 | 명령 줄 인수 144 |
  
145 | -b -c 1234 -d hoge -f 2345 -g fuga
146 | 
147 | 148 | 입력 파일: 149 |
  
150 | # config.txt
151 | # "#"는 주석 "//"에 해당
152 | option8 = str1 # 1 번째
153 | option8 = str2 # 두 번째도 ok
154 | option8 = str3 # 3 번째
155 | option8 = str4 # 4 번째
156 | option8 = str5 # 몇개든지 추가 할 수 있다
157 | 
158 | 159 | 결과: 160 |
  
161 | option2가 지정 되었다
162 | option3 : 1234
163 | option4 : hoge
164 | option5 : 10
165 | option6 : 2345
166 | option7 : fuga
167 | option8 : str1 str2 str3 str4 str5
168 | 
169 | 170 | 171 | -------------------------------------------------------------------------------- /redis/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | //#include 4 | //#include 5 | 6 | #include 7 | 8 | //namespace asio = boost::asio; 9 | //using boost::redis::connection; 10 | //using boost::redis::request; 11 | //using boost::redis::response; 12 | //using boost::redis::config; 13 | 14 | int main() 15 | { 16 | try { 17 | boost::redis::config cfg; 18 | cfg.use_ssl = false; 19 | cfg.addr.host = "127.0.0.1"; 20 | cfg.addr.port = 6379; 21 | 22 | 23 | //boost::redis::request req; 24 | //req.push("PING", "Hello world"); 25 | 26 | 27 | //boost::redis::response resp; 28 | /* 29 | asio::io_context ioc; 30 | boost::redis::connection conn{ ioc }; 31 | conn.async_run(cfg, {}, asio::detached); 32 | 33 | conn.async_exec(req, resp, [&](auto ec, auto) { 34 | if (!ec) 35 | std::cout << "PING: " << std::get<0>(resp).value() << std::endl; 36 | conn.cancel(); 37 | }); 38 | 39 | ioc.run();*/ 40 | 41 | } 42 | catch (std::exception const& e) { 43 | std::cerr << "Error: " << e.what() << std::endl; 44 | return 1; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /redis/redis.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30523.141 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "", "redis.vcxproj", "{D03145BA-42F6-4063-9FDB-1671CDD6D52C}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {D03145BA-42F6-4063-9FDB-1671CDD6D52C}.Debug|x64.ActiveCfg = Debug|x64 17 | {D03145BA-42F6-4063-9FDB-1671CDD6D52C}.Debug|x64.Build.0 = Debug|x64 18 | {D03145BA-42F6-4063-9FDB-1671CDD6D52C}.Debug|x86.ActiveCfg = Debug|Win32 19 | {D03145BA-42F6-4063-9FDB-1671CDD6D52C}.Debug|x86.Build.0 = Debug|Win32 20 | {D03145BA-42F6-4063-9FDB-1671CDD6D52C}.Release|x64.ActiveCfg = Release|x64 21 | {D03145BA-42F6-4063-9FDB-1671CDD6D52C}.Release|x64.Build.0 = Release|x64 22 | {D03145BA-42F6-4063-9FDB-1671CDD6D52C}.Release|x86.ActiveCfg = Release|Win32 23 | {D03145BA-42F6-4063-9FDB-1671CDD6D52C}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {FBA0E7F4-59C9-498D-A379-86C6956D239D} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /redis/redis.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {d03145ba-42f6-4063-9fdb-1671cdd6d52c} 25 | ConsoleApplication1 26 | 10.0 27 | Redis_01 28 | 29 | 30 | 31 | Application 32 | true 33 | v143 34 | Unicode 35 | 36 | 37 | Application 38 | false 39 | v143 40 | true 41 | Unicode 42 | 43 | 44 | Application 45 | true 46 | v143 47 | Unicode 48 | 49 | 50 | Application 51 | false 52 | v143 53 | true 54 | Unicode 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | true 76 | 77 | 78 | false 79 | 80 | 81 | true 82 | F:\Cpp\thirdparty\boost;$(IncludePath) 83 | F:\Cpp\thirdparty\boost\lib64-msvc-14.3;$(LibraryPath) 84 | 85 | 86 | false 87 | 88 | 89 | false 90 | 91 | 92 | 93 | Level3 94 | true 95 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 96 | true 97 | 98 | 99 | Console 100 | true 101 | 102 | 103 | 104 | 105 | Level3 106 | true 107 | true 108 | true 109 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 110 | true 111 | 112 | 113 | Console 114 | true 115 | true 116 | true 117 | 118 | 119 | 120 | 121 | Level3 122 | true 123 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 124 | true 125 | stdcpplatest 126 | 127 | 128 | Console 129 | true 130 | %(AdditionalDependencies) 131 | 132 | 133 | 134 | 135 | Level3 136 | true 137 | true 138 | true 139 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 140 | true 141 | 142 | 143 | Console 144 | true 145 | true 146 | true 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | -------------------------------------------------------------------------------- /redis/redis.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /reference_wrapper.md: -------------------------------------------------------------------------------- 1 | # 참조를 보관하는 컨테이너 2 | [출처](https://faithandbrave.hateblo.jp/entry/20110519/1305789940 ) 3 | 4 | 같은 기본 클래스를 승계한 클래스의 오브젝트가 몇개 있고, 이것들을 모아서 사용하고 싶은 경우와 전문특화해서 다루고 싶은 경우, 양쪽을 동시에 필요에 경우가 있다. 5 | 이럴 때 오브젝트의 참조를 보관하는 컨테이너가 필요하게 되는데 boost::reference_wrapper 컨테이너를 사용하면 좋다. 6 | 7 | ``` 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | struct Base { 16 | // 공통으로 사용하는 함수 17 | void print() const { std::cout << "print" << std::endl; } 18 | }; 19 | 20 | struct Integer : Base { 21 | // 전문 특화한 함수 22 | int get_int() const { return 3; } 23 | }; 24 | 25 | struct String : Base { 26 | // 전문 특화한 함수 27 | std::string get_string() const { return "Hello"; } 28 | }; 29 | 30 | int main() 31 | { 32 | Integer n; 33 | String s; 34 | 35 | std::vector > v; 36 | v.push_back(boost::ref(n)); 37 | v.push_back(boost::ref(s)); 38 | 39 | // 공통 함수를 사용한다 40 | BOOST_FOREACH (Base& base, v) { 41 | base.print(); 42 | } 43 | 44 | // 전문 특화한 함수를 사용한다 45 | const int v1 = n.get_int(); 46 | const std::string v2 = s.get_string(); 47 | } 48 | ``` 49 | 50 | 결과 51 |
52 | print
53 | print
54 | 
55 | -------------------------------------------------------------------------------- /resource/072012_1617_boost1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/072012_1617_boost1.png -------------------------------------------------------------------------------- /resource/072012_1617_boost2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/072012_1617_boost2.png -------------------------------------------------------------------------------- /resource/072012_1617_boost3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/072012_1617_boost3.png -------------------------------------------------------------------------------- /resource/072012_1617_boost4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/072012_1617_boost4.png -------------------------------------------------------------------------------- /resource/20120718163035.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/20120718163035.png -------------------------------------------------------------------------------- /resource/20120718163852.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/20120718163852.png -------------------------------------------------------------------------------- /resource/AsynchronousUDPClient_future.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/AsynchronousUDPClient_future.zip -------------------------------------------------------------------------------- /resource/ChattingTCPServer_spawn.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/ChattingTCPServer_spawn.zip -------------------------------------------------------------------------------- /resource/Eclipse_boost-1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/Eclipse_boost-1.PNG -------------------------------------------------------------------------------- /resource/Eclipse_boost-2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/Eclipse_boost-2.PNG -------------------------------------------------------------------------------- /resource/Eclipse_boost-3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/Eclipse_boost-3.PNG -------------------------------------------------------------------------------- /resource/Eclipse_boost-4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/Eclipse_boost-4.PNG -------------------------------------------------------------------------------- /resource/Eclipse_boost-5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/Eclipse_boost-5.PNG -------------------------------------------------------------------------------- /resource/Eclipse_boost-6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/Eclipse_boost-6.PNG -------------------------------------------------------------------------------- /resource/HttpClient.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/HttpClient.zip -------------------------------------------------------------------------------- /resource/VC10_setting-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/VC10_setting-1.png -------------------------------------------------------------------------------- /resource/VC10_setting-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/VC10_setting-2.png -------------------------------------------------------------------------------- /resource/VC10_setting-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/VC10_setting-3.png -------------------------------------------------------------------------------- /resource/asio_cpp11_future.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/asio_cpp11_future.png -------------------------------------------------------------------------------- /resource/asio_cpp11_packaged_task_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/asio_cpp11_packaged_task_01.png -------------------------------------------------------------------------------- /resource/asio_cpp11_packaged_task_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/asio_cpp11_packaged_task_02.png -------------------------------------------------------------------------------- /resource/asio_spawn_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/asio_spawn_01.png -------------------------------------------------------------------------------- /resource/asio_spawn_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/asio_spawn_02.png -------------------------------------------------------------------------------- /resource/boost_crc-001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/boost_crc-001.png -------------------------------------------------------------------------------- /resource/boost_crc-002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/boost_crc-002.png -------------------------------------------------------------------------------- /resource/boost_crc_01.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/boost_crc_01.zip -------------------------------------------------------------------------------- /resource/io_service_post_packaged_task.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/io_service_post_packaged_task.zip -------------------------------------------------------------------------------- /resource/mono_boost-1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/mono_boost-1.PNG -------------------------------------------------------------------------------- /resource/mono_boost-2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/mono_boost-2.PNG -------------------------------------------------------------------------------- /resource/mono_boost-3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/mono_boost-3.PNG -------------------------------------------------------------------------------- /resource/mono_boost-4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/mono_boost-4.PNG -------------------------------------------------------------------------------- /resource/mono_boost-5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/mono_boost-5.PNG -------------------------------------------------------------------------------- /resource/mono_boost-6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/mono_boost-6.PNG -------------------------------------------------------------------------------- /resource/ubuntu_boost_build-1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/ubuntu_boost_build-1.PNG -------------------------------------------------------------------------------- /resource/ubuntu_boost_build-2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/ubuntu_boost_build-2.PNG -------------------------------------------------------------------------------- /resource/ubuntu_boost_build-3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/ubuntu_boost_build-3.PNG -------------------------------------------------------------------------------- /resource/ubuntu_boost_build-4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/ubuntu_boost_build-4.PNG -------------------------------------------------------------------------------- /resource/ubuntu_boost_build-5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/ubuntu_boost_build-5.PNG -------------------------------------------------------------------------------- /resource/ubuntu_boost_build-6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/ubuntu_boost_build-6.PNG -------------------------------------------------------------------------------- /resource/vc_lib_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacking75/edu_cpp_Boost_Lib/3e5741e5cbd1773fa4ad8479e74f37ee642d74c5/resource/vc_lib_down.png -------------------------------------------------------------------------------- /signals2.md: -------------------------------------------------------------------------------- 1 | # boost::signals2 2 | 3 | 튜토리얼 http://docs.google.com/Doc?id=ddcwmgjq_12hdhr8tcw 4 | boostjp https://sites.google.com/site/boostjp/tips/signals 5 | boost::signals2 が便利そうな件について http://d.hatena.ne.jp/gintenlabo/20091201/1259671954 6 | Observerパタ?ン http://w.livedoor.jp/programming/d/Signals2 7 | Boost.Signals2 切? http://d.hatena.ne.jp/faith_and_brave/20110131/1296458381 8 | Boost.Signals2 を Boost.Parameter を使用して定義する http://d.hatena.ne.jp/osyo-manga/20110816/1313449833 9 | Boost.Signals2 で呼ばれる??に優先順位を付ける http://d.hatena.ne.jp/osyo-manga/20110815/1313366926 10 | デリゲ?トまたはイベントハンドラをC++で??するならBoost.FunctionよりもBoost.Signals2を使おう。 http://d.hatena.ne.jp/poyonon/20111110/1320933772 11 | C++ で、Model-View-Controller とか http://d.hatena.ne.jp/osyo-manga/20110721/1311240737 12 | シグナル・スロット(Signal/Slot)の仕組みをBoost.Signal2で試してみる http://qiita.com/kaoru/items/b8b39899ee4c771c2518 13 | boost::signals2 http://nekko1119.hatenablog.com/entry/20121108/1352356571 14 | 15 | 16 | -------------------------------------------------------------------------------- /string.md: -------------------------------------------------------------------------------- 1 | ## boost::algorithm::split(&Result, &Input, Pred, eCompress = token_compress_off) 2 | Pred(구분자) 문자열로 문자열 Input을 분해하고, 결과를 Result에 넣는다. 3 | Pred에는 공백 구분이라면 boost::algorithm::is_space(), (복수의)1 문자 구분자를 사용한다면 boost::algorithm::is_any_of()를 사용한다. 4 | 빈 문자열을 절약하기 원한다면 boost::algorithm::token_compress_on을 지정. 5 | default로 boost::algorithm::token_compress_off이 지정되어 있다. 6 | 7 | ``` 8 | #include 9 | namespace ba = boost::algorithm; 10 | 11 | string original = " \tABC DEFG HIJKL MNOPQ RSTU \t VWXYZ \t"; 12 | 13 | vector res; 14 | cout << "split(res,original,is_space())\n\t→"; 15 | ba::split( res, original, ba::is_space() ); 16 | for(size_t i=0; i < res.size(); ++i) cout << "[" << res[i] << "]"; cout< 29 | split(res,original,is_space()) 30 | →[][][ABC][DEFG][HIJKL][MNOPQ][RSTU][][][VWXYZ][][] 31 | split(res,original,is_any_of(" \tU")) 32 | →[][][ABC][DEFG][HIJKL][MNOPQ][RST][][][][VWXYZ][][] 33 | split(res,original,is_any_of(" \tU"),token_compress_on) 34 | →[][ABC][DEFG][HIJKL][MNOPQ][RST][VWXYZ][] 35 | 36 | 37 | 38 | 39 | ## boost::algorithm::join(const &Input, const &Separator) 40 | 문자열 시퀸스(string 배열이나 vector) Input을 Separator 문자열을 끼워 넣으면서 연결 41 | ``` 42 | string splited[] ={"join", "test", "!!!"}; 43 | cout << ba::join( splited, "__" ) << endl; 44 | ``` 45 | 46 | 결과 47 |
 48 | join__test__!!!
 49 | 
50 | 51 | 52 | 53 | ## 문자열 치환 boost::algorithm::replace_all_copy 54 | 예제 코드 55 | ``` 56 | #include 57 | #include 58 | 59 | int 60 | main(){ 61 | std::string source = "homuhomuhomu"; 62 | 63 | // 결과를 복사해서 반환한다 64 | auto result1 = boost::algorithm::replace_all_copy(source, "homu", "mado"); 65 | std::cout << result1 << std::endl; 66 | std::cout << source << std::endl; 67 | 68 | 69 | // 파괴적으로 변경한다 70 | boost::algorithm::replace_all(source, "homu", "mado"); 71 | std::cout << source << std::endl; 72 | 73 | return 0; 74 | } 75 | ``` 76 | 77 | 결과 78 |
 79 | madomadomado
 80 | homuhomuhomu
 81 | madomadomado
 82 | 
83 | 84 | 85 | 86 | ## string_ref 87 | - Boost 라이브러리 1.53에서 추가된 라이브러리로 문자열의 소유권은 없으며 다만 선두 포인터와 크기만을 가진 문자열 클래스 이다. 88 | - 이 라이브러리를 사용하면 좋은 예는 아래와 같다. 89 | 90 | ``` 91 | char szName[16]; 92 | void CheckName(const std::string& strName ); 93 | .... 94 | CheckName( szName ); 95 | ``` 96 | 97 | 위의 코드에서는 CheckName에 chat 타입의 문자열을 넘기면 임시적으로 string 오브젝트를 생성한다. CheckName 함수를 호출할 때 마다 불필요한 비용이 발생한다. 98 | 만약 아주 빈번하게 CheckName가 호출된다면 임시 오브젝트 생성과 삭제에 대한 비용이 꽤 문제가 될 수 있다. 99 | 100 | 바로 이런 부분에서 boost::string_ref를 사용하면 좋다. 101 | ``` 102 | void CheckName(const boost::string_ref& strName ); 103 | ``` 104 | 105 | 로 바꾸면 szName을 담기 위해 저장소를 만들 필요 없이 szName에 대한 포인터와 문자 길이만을 가진 오브젝트를 만들기 때문에 std::string에 비해서 비용이 아주 적다(문자열을 저장하기 위한 메모리 할당과 해제가 필요 없다!!!). 106 | 107 | boost::string_ref는 std::string와 비슷한 멤버를 대부분 가지고 있으나 c_str 멤버는 없다. 108 | boost::string_ref는 오리지널 문자열을 변경할 수 없고, 메모리 할당도 하지 않는다. 109 | -------------------------------------------------------------------------------- /timer.md: -------------------------------------------------------------------------------- 1 | 2 | ### 개요 3 | - 표준 라이브러리 clock()을 사용하여 간단하게 시간 계측을 할 때 사용하면 편리한 클래스 4 | 5 | 6 | ### 기본 사용 방법 7 | 8 | ``` 9 | // 출처: http://tips.hecomi.com/entry/20100715/1279210634 10 | #include 11 | #include 12 | #include 13 | 14 | int main() 15 | { 16 | boost::timer t; // 타이머 시작 17 | Sleep(1234); 18 | std::cout << t.elapsed() << " sec" << std::endl; // 1.234 sec 19 | t.restart(); // 타이머 리셋 20 | Sleep(2345); 21 | std::cout << t.elapsed() << " sec" << std::endl; // 2.344 sec 22 | return 0; 23 | } 24 | ``` 25 | elapsed 에서 경과한 시간을 double 타입으로 얻을 수 있다. restart 하면 타이머가 리셋되어 다시 0에서 카운트 된다. 26 | -------------------------------------------------------------------------------- /variant.md: -------------------------------------------------------------------------------- 1 | ### 다양한 타입 사용하기 2 | 3 | ``` 4 | // 출처: https://sites.google.com/site/boostjp/tips/variant 5 | #include 6 | #include 7 | #include 8 | 9 | struct var_printer : boost::static_visitor { 10 | void operator()(int x) const 11 | { 12 | std::cout << x << std::endl; 13 | } 14 | 15 | void operator()(std::string& s) const 16 | { 17 | std::cout << s << std::endl; 18 | } 19 | 20 | void operator()(double x) const 21 | { 22 | std::cout << x << std::endl; 23 | } 24 | }; 25 | 26 | int main() 27 | { 28 | std::cout << "저장" << std::endl; 29 | { 30 | boost::variant v; 31 | 32 | // 빈 상태 33 | std::cout << v.which() << std::endl; 34 | 35 | v = 1; // int 타입의 값 저장 36 | std::cout << v.which() << std::endl; 37 | 38 | v = 3.14; // double 타입의 값 저장 39 | std::cout << v.which() << std::endl; 40 | } 41 | 42 | std::cout << "타입 판정" << std::endl; 43 | { 44 | boost::variant v; 45 | 46 | v = 1; // int 타입의 값 저장 47 | if (v.type() == typeid(int)) { 48 | std::cout << "int" << std::endl; 49 | } 50 | 51 | v = 3.14; // double 타입의 값 저장 52 | if (v.type() == typeid(double)) { 53 | std::cout << "double" << std::endl; 54 | } 55 | } 56 | 57 | std::cout << "값 얻기" << std::endl; 58 | { 59 | boost::variant v; 60 | v = 1; 61 | 62 | // 참조 63 | try { 64 | int& x = boost::get(v); 65 | std::cout << x << std::endl; 66 | } 67 | catch (boost::bad_get& e) { 68 | std::cout << e.what() << std::endl; 69 | } 70 | 71 | // 포인터 72 | if (int* x = boost::get(&v)) { 73 | std::cout << *x << std::endl; 74 | } 75 | else { 76 | std::cout << "int 값은 저장 되어 있지 않다." << std::endl; 77 | } 78 | } 79 | 80 | std::cout << "값 비우기" << std::endl; 81 | { 82 | boost::variant v = boost::blank(); 83 | v = 3; 84 | 85 | v = boost::blank(); 86 | 87 | if (v.type() == typeid(boost::blank)) { 88 | std::cout << "blank" << std::endl; 89 | } 90 | else { 91 | std::cout << "no blank" << std::endl; 92 | } 93 | } 94 | 95 | std::cout << "타입에 맞는 함수 호출하기" << std::endl; 96 | { 97 | // int, string, double 98 | boost::variant v; 99 | 100 | v = 3; // int 101 | boost::apply_visitor(var_printer(), v); // visitor으로 타입에 맞는 처리를 한다. 102 | 103 | v = "hello"; // string 104 | boost::apply_visitor(var_printer(), v); 105 | } 106 | 107 | 108 | return 0; 109 | } 110 | ``` 111 | 112 | 113 | ### Boost.Variant로 상속을 대체 114 | - 출처 https://sites.google.com/site/boostjp/tips/variant 115 | ``` 116 | #include 117 | #include 118 | #include 119 | #include 120 | #include 121 | 122 | 123 | struct Background { 124 | void update() 125 | { 126 | std::cout << "background" << std::endl; 127 | } 128 | }; 129 | 130 | struct Character { 131 | void update() 132 | { 133 | std::cout << "character" << std::endl; 134 | } 135 | }; 136 | 137 | struct Effect { 138 | void update() 139 | { 140 | std::cout << "effect" << std::endl; 141 | } 142 | }; 143 | 144 | struct UpdateVisitor { 145 | using result_type = void; 146 | 147 | template 148 | void operator()(T& x) 149 | { 150 | x.update(); 151 | } 152 | }; 153 | 154 | class TaskList { 155 | using TaskType = boost::variant; 156 | std::vector taskList_; 157 | public: 158 | void update() 159 | { 160 | for (TaskType& x : taskList_) { 161 | UpdateVisitor vis; 162 | boost::apply_visitor(vis, x); 163 | } 164 | } 165 | 166 | template 167 | void add(Args... args) 168 | { 169 | taskList_.push_back(Task(args...)); 170 | } 171 | }; 172 | 173 | int main() 174 | { 175 | TaskList task; 176 | task.add(); 177 | task.add(); 178 | task.add(); 179 | 180 | task.update(); 181 | 182 | return 0; 183 | } 184 | ``` 185 | 186 | 위 구현을 기존에는 아래처럼 인터페이스를 상속해서 구현하였다. 187 | ``` 188 | struct UpdateInterface { 189 | virtual void update() = 0; 190 | }; 191 | 192 | struct Background : public UpdateInterface { 193 | void update() override 194 | { 195 | std::cout << "background" << std::endl; 196 | } 197 | }; 198 | 199 | struct Character : public UpdateInterface { 200 | void update() override 201 | { 202 | std::cout << "character" << std::endl; 203 | } 204 | }; 205 | 206 | struct Effect : public UpdateInterface { 207 | void update() override 208 | { 209 | std::cout << "effect" << std::endl; 210 | } 211 | }; 212 | 213 | class TaskList { 214 | std::vector> taskList_; 215 | public: 216 | void update() 217 | { 218 | for (UpdateInterface& x : taskList_ | boost::adaptors::indirected) { 219 | x.update(); 220 | } 221 | } 222 | 223 | template 224 | void add(Args... args) 225 | { 226 | taskList_.push_back(std::unique_ptr(new Task(args...))); 227 | } 228 | }; 229 | 230 | int main() 231 | { 232 | TaskList task; 233 | task.add(); 234 | task.add(); 235 | task.add(); 236 | 237 | task.update(); 238 | } 239 | ``` 240 | --------------------------------------------------------------------------------