{"version":"1.0","url":"https://faithandbrave.hateblo.jp/entry/20081222/1229936810","type":"rich","title":" C++0x explicit bool","blog_title":"Faith and Brave - C++\u3067\u904a\u307c\u3046","author_name":"faith_and_brave","image_url":null,"height":"190","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Ffaithandbrave.hateblo.jp%2Fentry%2F20081222%2F1229936810\" title=\" C++0x explicit bool - Faith and Brave - C++\u3067\u904a\u307c\u3046\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","provider_url":"https://hatena.blog","description":"\u30b9\u30de\u30fc\u30c8\u30dd\u30a4\u30f3\u30bf\u306e\u3088\u3046\u306a\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3059\u308b\u5834\u5408\u3001if\u6587\u3067\u30cc\u30eb\u30dd\u30a4\u30f3\u30bf\u304b\u3069\u3046\u304b\u5224\u5b9a\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u306b operator bool\u3092\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002 template <class T> class smart_ptr { T* p_; public: operator bool() const { return p_ != 0; } }; smart_ptr<int> p; // OK if (p) { // \u30dd\u30a4\u30f3\u30bf\u306f\u6709\u52b9 } else { // \u30dd\u30a4\u30f3\u30bf\u306f\u7121\u52b9 } \u3057\u304b\u3057\u3001\u3053\u306e\u65b9\u6cd5\u3067\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u610f\u5473\u306e\u306a\u3044\u30b3\u30fc\u30c9\u3082\u30b3\u30f3\u30d1\u30a4\u30eb\u304c\u901a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002 float f = p; int x \u2026","provider_name":"Hatena Blog","width":"100%","blog_url":"https://faithandbrave.hateblo.jp/","published":"2008-12-22 18:06:50","author_url":"https://blog.hatena.ne.jp/faith_and_brave/","categories":["C++"]}