Enlightening Usage of C++11 decltype

后端 未结 3 1759
醉梦人生
醉梦人生 2020-12-15 07:46

I\'ve just seen this really nice talk Rock Hard: C++ Evolving by Boris Jabes. In the section of the talk concerning Higher-Order Generic Programming he say

3条回答
  •  一整个雨季
    2020-12-15 08:31

    std::for_each(c.begin(), c.end(), [](decltype (c.front()) val){val*=2;});
    

    Autodeducting the value_type of the container c can't be done without decltype.

提交回复
热议问题