終了
以前UMLは素人を騙すくらいにしか役に立たないらしい。 - 並列メモ?と言うのを書いたのだが、これについてリアルワールドで反論せずblogで愚痴るのは…とかなんとかdisられたらしい。
で、それに反論してみようかとも思ったのだが、面倒なのでこのblog自体を止めることにした。それでは皆さん、さよーならー(^^)/~~
Boost C++ Libraryのお勉強その14
Boost.MemberFunction
memberをmemと略すのはどうなんだろ。cの標準ライブラリ的にmemはmemoryの略だよな。
#include <iostream> #include <vector> #include <algorithm> #include <boost/mem_fn.hpp> class Dummy { private: int e_; public: Dummy(int e) : e_(e) {} void fun(void) { std::cout << e_ << std::endl; } }; int main(void) { std::vector < Dummy > v; v.push_back(Dummy(1)); v.push_back(Dummy(2)); v.push_back(Dummy(3)); std::for_each(v.begin(), v.end(), boost::mem_fn(&Dummy::fun)); return 0; }
1 2 3
Boost.MinMax
minとmaxを一度に返すもの。こういう細々とした便利関数は重要だと思う。どのくらいの頻度で必要になるかは分からないが…。
#include <iostream> #include <boost/tuple/tuple_io.hpp> #include <boost/algorithm/minmax.hpp> int main(void) { std::cout << boost::minmax(1, 0) << std::endl; return 0; }
(0, 1)
Boost.MultiArray
領域は連続しているらしい。
#include <iostream> #include <iterator> #include <algorithm> #include <boost/multi_array.hpp> int main(void) { boost::multi_array < int, 3 > ma(boost::extents[2][2][2]); boost::multi_array < int, 3 >::index i, j, k; for (i = 0; i < 2; ++i) { for(j = 0; j < 2; ++j) { for(k = 0; k < 2; ++k) { ma[i][j][k] = 1; } } } return 0; }
Boost C++ Libraryのお勉強その13
数学関係が多いので、豪快に素通りしてみる。
Boost.Mpi
頑張ってはみたものの、コンパイル環境が構築できず。
Boost.Mpl
言語の当初想定をはるかに超えてしまったっぽいやつ。そのうち頑張って使いこなしてみたい気がしないでもないが、コンパイル時間の限界への挑戦と、そこまでしてC++に固執するのかという問に答えが見出せるかどうかにかかっているかも。
#include <iostream> #include <typeinfo> #include <boost/mpl/if.hpp> int main(void) { using namespace boost::mpl; if_ < bool_ < sizeof(long) == 8 > , long, long long >::type tmp; std::cout << typeid(tmp).name() << std::endl; }
l
Boost.Math
複素数用の関数とか。パス。
Boost.Octonions
八元数?よく分からんのでパス。
Boost.Quaternions
四元数?よく分からんのでパス。
Boost.MathToolkit
数学ネタ多いな。パス。
なんかgoogleとかいう検索エンジンの結果が
片っ端から「このサイトはコンピュータに損害を与える可能性があります。」とかくっつけてるけど、何かあったのか?バグったのか?
2009年1月の記録
日帰りで2回。
Boost C++ Libraryのお勉強その12
http://www.boost.org/doc/libs/1_35_0
webブラウザのスクロールバーの位置からすると、やっと半分てところか。
Boost.Iostream
IO streamが簡単に作れる仕組み。
#include <iostream> #include <boost/iostreams/stream.hpp> #include <boost/iostreams/concepts.hpp> class zero : public boost::iostreams::source { public: std::streamsize read(char * s, std::streamsize n) { *s = '0'; return 1; } }; int main(void) { char c; zero z; boost::iostreams::stream <zero> s(z); s >> c; std::cout << c << std::endl; return 0; }
Boost.Iterator
イテレータ色々。
#include <iostream> #include <numeric> #include <boost/iterator/counting_iterator.hpp> int main(void) { boost::counting_iterator<int> s(1); boost::counting_iterator<int> e(10); std::cout << std::accumulate(s, e, 0) << std::endl; }
45
Boost.Lambda
無名関数環境付きとかそんな感じのもの。感動の一品ではあるが、流石にメンバ関数呼び出しとかはキツい…。
#include <iostream> #include <vector> #include <algorithm> #include <boost/lambda/lambda.hpp> int main(void) { using namespace boost::lambda; std::vector < int > v; v.push_back(1); v.push_back(2); v.push_back(3); int sum = 0; std::for_each(v.begin(), v.end(), sum += _1); std::cout << sum << std::endl; return 0; }
6