Makers Blog

Linq the list processing library for C++

Peer PLCnext Team 09 December 2020 min. read
272 views 0 comments


In this article I will explain how to use linq to process data. With this library you can use filtering, selections, aggregations, groupings and many more. For full support it requires clang or gcc, and boost

How to use

This library is a Header only library. You only have to integrate the C++ header in your project environment. When you’re done you can use the linq functions.


    std::vector<int> v = { 1, 2, 4 };

    //linq form
    auto q = LINQ(from(x, v) select(x * 3));

    //q -> result {3,6,12}

    //extension form
    auto r = v 
        | linq::select([](int x) { return x * 3; });


    std::vector<int> v = { 4, 2, 8 };

    //linq form
    auto q = LINQ(from(x, v) orderby( descending x) select(x));

    //q -> result {8,4,2}


    vector<int> v = { 1, 3, 4, 5 };

    auto q = LINQ(from(i, v) where(i % 2));

    //q -> result {4}

    //extension form
    auto r = v 
        | linq::where([](int x){ return x % 2})
        | linq::select([](int x) { return x; });

More Information

If you are interested in getting more information about linq you can check the folowing links:


The library is published under Boost Software License 1.0


The Makers Blog shows applications and user stories of community members that are not tested or reviewed by Phoenix Contact. Use them at your own risk.


Please login/register to comment


Leave a Reply

Never miss a new article
Sign up for the newsletter
Never miss news about PLCnext Technology
Get interesting content via newsletter four times a year
Receive exclusive information before all other users