{"type":"rich","published":"2014-01-03 05:58:52","title":" Boost.Variant \u304c\u7279\u5b9a\u306e\u578b\u306e\u5024\u3092\u4fdd\u6301\u3057\u3066\u3044\u305f\u6642\u3060\u3051\u51e6\u7406\u3092\u5b9f\u884c\u3059\u308b","author_name":"rhysd","height":"190","author_url":"https://blog.hatena.ne.jp/rhysd/","url":"https://rhysd.hatenablog.com/entry/2014/01/03/055852","categories":["C++","Boost"],"blog_url":"https://rhysd.hatenablog.com/","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Frhysd.hatenablog.com%2Fentry%2F2014%2F01%2F03%2F055852\" title=\" Boost.Variant \u304c\u7279\u5b9a\u306e\u578b\u306e\u5024\u3092\u4fdd\u6301\u3057\u3066\u3044\u305f\u6642\u3060\u3051\u51e6\u7406\u3092\u5b9f\u884c\u3059\u308b - \u306f\u3084\u304f\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u306a\u308a\u305f\u3044\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","description":"boost::variant \u304c\u4fdd\u6301\u3057\u3066\u3044\u308b\u5024\u306e\u578b\u304c\u7279\u5b9a\u306e\u578b\u306e\u5834\u5408\u3060\u3051\u25cb\u25cb\u3059\u308b\u3068\u3044\u3046\u51e6\u7406\u304c\u591a\u3044\u306e\uff0c\u3067\u30e9\u30e0\u30c0\u5f0f\u3067\u51e6\u7406\u3092\u66f8\u3051\u308b\u3088\u3046\u306b\u3057\u305f\uff0e apply<{\u671f\u5f85\u3059\u308b variant \u304c\u4fdd\u6301\u3059\u308b\u5024\u306e\u578b}>({variant \u306a\u5909\u6570}, {\u9069\u7528\u3057\u305f\u3044\u95a2\u6570}) \u3068\u3044\u3046\u611f\u3058\u306b\u4f7f\u3046\uff0e #include <boost/variant/variant.hpp> #include <iostream> int main() { boost::variant<int, double> v = 42; std::cout << *apply<int>(v, [](auto i){ return i * 3; }) <<\u2026","version":"1.0","width":"100%","provider_url":"https://hatena.blog","blog_title":"\u306f\u3084\u304f\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u306a\u308a\u305f\u3044","image_url":null,"provider_name":"Hatena Blog"}