简体   繁体   中英

generic lambdas in c++14

I'm trying to compile the following code in VS2019:

auto moveToEnd = []<typename T>(std::vector<T>& into, std::vector<T>& from)
{
    into.insert(std::end(into), std::make_move_iterator(std::begin(from))
        , std::make_move_iterator(std::end(from)));
};

However, I get an error:

'<' skipping unexpected token/s before lambda body

Note: I'm using a C++14 compiler.

Those ain't the regular generic lambdas. Specifying the template parameter list for a lambda is a C++20 feature. The C++14 "generic lambdas" merely let you use auto in lambda parameters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM