-
- Notifications
You must be signed in to change notification settings - Fork 264
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
C++ Insights link: https://cppinsights.io/s/f1515a7d
void f() { std::priority_queue<int, std::vector<int>, decltype([](int lhs, int rhs) { return lhs > rhs; })> min_heap; } translates into
void f() { class __lambda_8_34 { ... }; std::priority_queue<int, std::vector<int, std::allocator<int> >, __lambda_8_34> min_heap = __lambda_8_34{}; } which is not valid C++ code:
error: conversion from 'f()::__lambda_8_34' to non-scalar type 'std::priority_queue<int, std::vector<int, std::allocator<int> >, f()::__lambda_8_34>' A slightly modified function, where the lambda is defined before the std::priority_queue:
void g() { auto cmp_greater = [](int lhs, int rhs) { return lhs > rhs; }; std::priority_queue<int, std::vector<int>, decltype(cmp_greater)> min_heap; } translates into
void g() { class __lambda_13_24 { ... }; __lambda_13_24 cmp_greater = __lambda_13_24{}; std::priority_queue<int, std::vector<int, std::allocator<int> >, __lambda_13_24> min_heap = std::priority_queue<int, std::vector<int, std::allocator<int> >, __lambda_13_24>(); } which is valid C++ code.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working