码迷,mamicode.com
首页 > 编程语言 > 详细

The Usage of Lambda and Heap in the C++ STL

时间:2017-12-25 11:33:40      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:ssi   compare   entity   cto   down   c++   val   str   markdown   

The Usage of Lambda and Heap in the C++ STL

Heap

In c++ STL, the heap had been implemented as the priority_queue.

Lambda with STL

To use decltype to inspects the declared type of an entity or the type and value category of an expression.

Code Example

// Using lambda to compare elements.
auto cmp = [](int left, int right) { return left < right;};
std::priority_queue<int, std::vector<int>, decltype(cmp)> heap(cmp);

Reference

http://en.cppreference.com/w/cpp/container/priority_queue

The Usage of Lambda and Heap in the C++ STL

标签:ssi   compare   entity   cto   down   c++   val   str   markdown   

原文地址:http://www.cnblogs.com/fengyubo/p/8107941.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!