How to use lambda auto parameters in C++11

前端 未结 5 745
野的像风
野的像风 2020-12-05 10:33

I have a code in C++14. However, when I used it in C++11, it has an error at const auto. How to use it in C++11?

vector &g         


        
5条回答
  •  不思量自难忘°
    2020-12-05 10:51

    Alternatively you can directly use the value_type typedef of the container with a decltype, like

    std::stable_sort(X.rbegin(), X.rend(),
                     [](const decltype(X)::value_type & lhs, 
                        const decltype(X)::value_type & rhs)
                        {return lhs.first < rhs.first; }
                    );
    

提交回复
热议问题