First define the lambda object, then pass it to the template’s type using decltype
and also pass it directly to the constructor.
auto comp = []( adjist a, adjlist b ) { return a.second > b.second; };
priority_queue< adjlist_edge , vector<adjlist_edge>, decltype( comp ) >
adjlist_pq( comp );
More Related Contents:
- Are lambdas inlined like functions in C++?
- Can the ‘type’ of a lambda expression be expressed?
- push_back vs emplace_back
- A positive lambda: ‘+[]{}’ – What sorcery is this? [duplicate]
- Is std::unique_ptr required to know the full definition of T?
- Why can I not push_back a unique_ptr into a vector?
- Why do I get the same sequence for every run with std::random_device with mingw gcc4.8.1?
- Why does C++11’s lambda require “mutable” keyword for capture-by-value, by default?
- How to capture a unique_ptr into a lambda expression?
- Why can’t simple initialize (with braces) 2D std::array? [duplicate]
- Nice way to append a vector to itself
- Is constexpr supported with lambda functions / expressions?
- Why use non-member begin and end functions in C++11?
- The simplest and neatest c++11 ScopeGuard
- std::vector, default construction, C++11 and breaking changes
- Why are lambda expressions not allowed in an unevaluated operands but allowed in the unevaluated portions of constant expressions?
- Why is value taking setter member functions not recommended in Herb Sutter’s CppCon 2014 talk (Back to Basics: Modern C++ Style)?
- Capturing perfectly-forwarded variable in lambda
- Lambda capture and parameter with same name – who shadows the other? (clang vs gcc)
- Non-copyable elements in vector
- C++11 “overloaded lambda” with variadic template and variable capture
- C++11 STL containers and thread safety
- How can I use Standard Library (STL) classes in my dll interface or ABI?
- Do c++11 lambdas capture variables they don’t use?
- Passing a lambda into a function template
- Can std::vector emplace_back copy construct from an element of the vector itself?
- Why vector access operators are not specified as noexcept?
- How can I pass a C++ lambda to a C-callback that expects a function pointer and a context?
- Specializing a template on a lambda in C++0x
- Lambdas and std::function