cpplinq: An introduction

cpplinq is a C++ template library that provides .NET-like query operators for sequences of objects in C++11. cpplinq is an open-source library that works both with VC++ compilers (2010 and 2012) and gcc (4.7.0 is the version used for unit tests). The library supports most of the .NET query operators and is extendable with additional operators that can suite some particular use. If you’re not familiar with .NET query operators, this article, http://msdn.microsoft.com/en-us/library/bb394939.aspx, lists and explain them.

The light-weighted library consists of a series of template classes and helper methods, provided in a single header under the namespace cpplinq.

This is a short introduction to the library. More posts will follow. Let’s see some examples.

The following code retrieves all the prime numbers from an array.

A slightly variation produces a sequence of first N prime numbers and transforms them into strings.

The next sample retrieves all the orders from a customer.

Callinq print_orders_by_cust() with argument 1 would print:

On the other hand, if you want to print the last order from a particular customer, the function above would change to something like this:

Calling print_last_order_for_customer() with argument 1 would print:

Hopefully this provides a quick view over the capabilities of the library. In following posts I will show more examples and discuss some of the query operators. To learn more about the library see the following articles:

, , , , , Hits for this post: 15895 .
Trackback

2 comments untill now

  1. Gravatar
    John Schroedl @ 2012-10-25 18:10

    This looks pretty fantastic! I will definitely be checking it out.

    John

  2. Gravatar

    Very, very slick. Thanks for sharing!

Add your comment now