2010-03-09から1日間の記事一覧

GCC 4.5から使用可能なC++0x機能

以下の4つです。 #include <iostream> #include <vector> #include <algorithm> template <class T> class smart_ptr { T* p_; public: smart_ptr() : p_(0) {} explicit operator bool() const // 1.明示的な型変換演算子 { return p_ != 0; } }; int main() { smart_ptr<int> p; if (p) {} // int x = </int></class></algorithm></vector></iostream>…