{"title":"auto as \u30e9\u30e0\u30c0\u5f0f\u306e\u623b\u308a\u5024\u578b","type":"rich","published":"2016-06-01 00:00:00","version":"1.0","url":"https://yohhoy.hatenadiary.jp/entry/20160601/p1","categories":["C++"],"provider_url":"https://hatena.blog","author_name":"yohhoy","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fyohhoy.hatenadiary.jp%2Fentry%2F20160601%2Fp1\" title=\"auto as \u30e9\u30e0\u30c0\u5f0f\u306e\u623b\u308a\u5024\u578b - yohhoy\u306e\u65e5\u8a18\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","width":"100%","author_url":"https://blog.hatena.ne.jp/yohhoy/","image_url":null,"provider_name":"Hatena Blog","blog_title":"yohhoy\u306e\u65e5\u8a18","blog_url":"https://yohhoy.hatenadiary.jp/","height":"190","description":"C++14\u4ee5\u964d\u3067\u306f\u3001\u30e9\u30e0\u30c0\u5f0f\u306e\u623b\u308a\u5024\u578b(trailing-return-type)\u3068\u3057\u3066auto\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u6307\u5b9a\u3067\u304d\u308b\u3002*1 // C++11\u3067\u306fNG\uff0fC++14\u4ee5\u964d\u306fOK auto f = [](int a, int b) -> auto { // int\u578b\u306b\u63a8\u8ad6 return a + b; }; auto h = [](auto& v) -> decltype(auto) { return v; }; int i = 42; int &ri = h(i); // int&\u578b\u306b\u63a8\u8ad6 C++14 5.1.2/p4, 7.1.6.4/p1\u3088\u308a\u5f15\u7528\uff08\u4e0b\u7dda\u90e8\u306f\u5f37\u8abf\uff09\u3002 4 If a lambda-e\u2026"}