Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Given C++('11) has lambdas now, will there be any LINQ like higher order function library officially supported later? Is there any such library now being used in any production level code?

Obviously I'm not expecting the SQL-like expression tree based LINQ query syntax in C++. I am talking about the lambda based one. So, no new language feature in needed in C++'11, just a library will do.

share|improve this question
    
With LINQ you mean LINQ to Objects? Or did you mean the whole LINQ incl. XML and SQL? –  mbx Aug 16 '11 at 7:48
    
@mbx Yes. I mean LINQ-to-objects only. –  Gulshan Aug 16 '11 at 9:05
    
btw, SQL-like expression tree based LINQ query syntax is not something impossible in C++, stuff like boost::proto let people write DSEL now –  lurscher Apr 8 '12 at 23:20

3 Answers 3

LINQ-to-objects is already supported in the Standard library and has been since it's inception. The syntax is just a bit different- it was never intended to emulate SQL and has way too many iterators in it. You can make it more reminiscent without too big a hassle.

Edit: When actually attempting to make it more reminiscent without too big a hassle, I determined that it actually could be a significant hassle. It is, however, still completely possible.

share|improve this answer
    
The syntax is just a bit different is that a euphemism?! –  mbx Aug 16 '11 at 11:09
    
@mbx: No, that's how it is. And as my post demonstrates, it's trivial to alter that syntax. –  DeadMG Aug 16 '11 at 11:30
4  
You might want to explain how to actually use this? –  JohnB Aug 16 '11 at 11:46
1  
Yeah, I realized that it wasn't exactly a finished product. –  DeadMG Aug 16 '11 at 12:07

Notes : For C++2011 there is not such functionality. Fortunately, the next C++ should include a filesystem library (see boost::filesystem) so you can guess that such a database library will not be standardized soon.

There are several (and some recent) discussions on the boost mailing list about such library. Several people are pointing to potential boost-like libraries like SOCI and CPPDB.

Also, I don't see how lambdas can help for such a functionality. Lambdas are still code, not EDSL constructs.

share|improve this answer
    
I didn't Linq-to-sql with Linq. It was about the lambda based method chaining. –  Gulshan Nov 2 '11 at 6:41

There's ODB which is interesting.

see the sample code from the ODB wikipedia entry that searches for all people called Doe younger than 30 (age and last are DB columns, directly mapped to a class, this is done by the ODB compiler to it always keeps automatically generated classes in sync with the DB schema, without having to modify a DB->code mapping definition file or assembly). I like it because of that, having had to maintain an Entity Framework assembly.

  transaction t(db.begin ());

  result r(db.query<person>(query::last == "Doe" && query::age < 30));

  for (result::iterator i (r.begin ()); i != r.end (); ++i)
  {
    cout << "Hello, " << i->first () << endl;
  }

  t.commit ();
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.