{"height":"190","published":"2012-01-19 00:09:43","author_name":"osyo-manga","version":"1.0","author_url":"https://blog.hatena.ne.jp/osyo-manga/","categories":["C++"],"provider_name":"Hatena Blog","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fosyo-manga.hatenadiary.org%2Fentry%2F20120119%2F1326899383\" title=\"constexpr \u3067\u30a8\u30e9\u30fc\u51fa\u529b - C++\u3067\u30b2\u30fc\u30e0\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","image_url":null,"title":"constexpr \u3067\u30a8\u30e9\u30fc\u51fa\u529b","url":"https://osyo-manga.hatenadiary.org/entry/20120119/1326899383","type":"rich","provider_url":"https://hatena.blog","width":"100%","description":"\u4f8b\u3048\u3070\u3001\u6b21\u306e\u3088\u3046\u306a\u9664\u7b97\u3092\u884c\u3046\u95a2\u6570\u3067\u3001\u30bc\u30ed\u9664\u7b97\u306e\u5834\u5408\u306b\u30a8\u30e9\u30fc\u3092\u51fa\u529b\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002 constexpr int division(int a, int b){ return a / b; } constexpr int x1 = division(4, 2); // ok constexpr int x2 = division(4, 0); // \u30bc\u30ed\u9664\u7b97\u3092\u884c\u3046\u306e\u3067\u30a8\u30e9\u30fc \u672c\u5f53\u306a\u3089\u95a2\u6570\u5185\u3067 static_assert(b == 0, \"division by zero\") \u3068\u66f8\u304d\u305f\u3044\u306e\u3067\u3059\u304c\u3001\u6b8b\u5ff5\u306a\u304c\u3089\u95a2\u6570\u5185\u3067 b \u304c constexpr \u304b\u5224\u65ad\u3059\u308b\u4e8b\u306f\u51fa\u6765\u306a\u3044\u306e\u3067 static_assert\u2026","blog_url":"https://osyo-manga.hatenadiary.org/","blog_title":"C++\u3067\u30b2\u30fc\u30e0\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0"}