C++

コンパイル高速化比較メモ

開発に参加してる某プログラムパッケージのMLで、g++よりclangの方が速いぜ的な話が(Macユーザから)あり、一応Linuxでもソースにパッチを当てればclangでも通るようになった*1ので、コンパイル時間を比較してみた。あと 漢(オトコ)のコンピュータ道: MySQL…

コーディング規則

たとえばif-else構文で、 if (cond) { method1(); } else { method2(); } と書く流儀と、 if (cond) { method1(); } else { method2(); } と書く流儀がある。 vimで set foldmethod=syntax しておくと、文法上の構造に応じて折り畳んでくれるのだが、このと…

std::vectorとコピーコンストラクタ

const使わないとvectorに怒られる。 #include <vector> #include <iostream> using namespace std; struct A { double x; A () : x(0.0) {} A (const A &a) { cout << "copy constructor of A" << endl; x = a.x; } }; int main () { A a; vector<A> as1, as2; cout << "as1.push_</a></iostream></vector>…

コピーコンストラクタ

当たり前といえば当たり前なんだけど確認。 #include <iostream> using namespace std; struct A { double x; A () : x(0.0) {} A (A &a) { cout << "copy constructor of A" << endl; x = a.x; } A &operator= (double xx) { cout << "operator= of A" << endl; x = x</iostream>…