2009-02-01から1ヶ月間の記事一覧

Version 1.8が出ている

とりあえず、ダウンロード。インストールは明日以降。C++関係の変更点 The C and C++ compilers now have diagnostics for meaningless comparision of 64-bit and bit-field operands. The C and C++ compilers now have conversion tables from CP=1250,12…

コンパイルできない。

C++

おや、VCってfor文の制御式で変数の宣言ができないのか。 class foo { public: foo(int){} operator bool() const { return false; } ~foo(){} }; int main() { for(;foo x=0;) ; return 0; } どうも、デストラクタをもっているとだめなようだ。誰かバグ報告…

複合代入演算子の等号の位置が逆

C

ときどきの雑記帖 i戦士篇 09/2/9より K&R以前の仕様なんて普通の人は知らないよなぁ。 大昔に一度だけ、この仕様ではまって以来、=の前後に空白を入れる癖がついてしまった。 あと噂で聞いたんだけど、初期化子で等号が必要なかったって本当なの? int x 3; …

funnyクラスを作ってみた。その2

C++

funnyの色々な使い方。 // メンバ関数を呼び出す。 template <class T,class U,class V,class W> class speak_type:public U { public: void speak() const { static_cast<const T*>(this)->data()->speak(); } struct interface { virtual void speak() const=0; }; }; class dog { public: void speak(</const></class>…

funnyクラスを作ってみた。その1

C++

boostのfunctionとanyを合わせたようなクラスを作ってみた。 対応コンパイラは、VCとGCCのみ。 variadic templatesの使用推奨。簡単な使用例。 #include <iostream> #include <cstdlib> #include "funny.h" int main() { funny<> x; x = 1; std::cout << (int)x << std::endl; x</cstdlib></iostream>…