tag:blogger.com,1999:blog-8715120618224381002.post3861584726507616259..comments2024-01-31T05:36:46.775+00:00Comments on This is an EX blog...: VC++16 has decltype in Beta 1 (so Linq to C++0x looks a little nicer)Danielhttp://www.blogger.com/profile/11384619047799752406noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-8715120618224381002.post-8297320921233189912011-01-14T14:12:47.973+00:002011-01-14T14:12:47.973+00:00@Eelco - it compiles fine, try building and runnin...@Eelco - it compiles fine, try building and running it. That error is a bug in the Intellisense engine (which uses a different compiler).Danielhttps://www.blogger.com/profile/11384619047799752406noreply@blogger.comtag:blogger.com,1999:blog-8715120618224381002.post-79491924763990056842011-01-13T22:04:02.344+00:002011-01-13T22:04:02.344+00:00Hi Daniel,
First of all, thanks a lot for this gr...Hi Daniel,<br /><br />First of all, thanks a lot for this great example; I am programming in both C++ and C# at the time, and I find I sorely miss LINQ, or even halfway decent support for lazy collection manipulation in C++.<br /><br />However, for reasons that are beyond my template-fu, your example code does not compile under MSVS2010 professional. To be specific, the error I get is:<br /><br />"IntelliSense: no instance of function template "filter::select [with TElemFrom=int, TElemTo=int, TIterFrom=filter>>, pass_thru, always_true>::const_iterator, TSelector=pass_thru, TPredicate=lambda []bool (int n)->bool]" matches the argument list"<br /><br />The filter function works perfectly fine, however.<br /><br /><br />Secondly, id have to respectfully disagree with the notion that this code does not fill a useful niche; after wrestling with the rather convoluted boost implementation for a day, I discovered its doesnt accept C++0x lambdas. Great; goodbye improved elegance. I might as well go back to handcrafting my loops then.<br /><br />Your implementation seems a lot simpler; exactly what 99% of people will be looking for 99% of the time. Too bad I cant get it to work though :(.EHhttps://www.blogger.com/profile/15747170254613600308noreply@blogger.comtag:blogger.com,1999:blog-8715120618224381002.post-38226350193532379722009-05-26T13:23:06.826+01:002009-05-26T13:23:06.826+01:00Thanks, but I'm not sure there's a need:
http://w...Thanks, but I'm not sure there's a need:<br /><br />http://www.boost.org/doc/libs/1_39_0/libs/iterator/doc/index.html<br /><br />That boost library is essentially the same idea, first implemented nearly a decade ago by the god-like David Abrahams. "transform_iterator" does the same thing as "select", "filter_iterator" the same as "where".<br /><br />What makes my little example look nicer is (a) lambdas, which could just as easily be used with boost interator adaptors, and (b) the fact that I wrap containers (pairs of iterators or "ranges") instead of individual iterators, which is less flexible but much more readable.<br /><br />But there is also this:<br /><br />http://www.boost.org/doc/libs/1_39_0/libs/range/doc/utility_class.html#iter_range<br /><br />Which captures the idea of a pair of iterators. So combine boost range and boost iterator adaptors, and you have a much more solid foundation for all this stuff. I was just using the raw language features and the more traditional concepts of the std library to demonstrate lambdas and communicate these ideas in .NET terms.<br /><br />Maybe if I get some time I'll post a rewrite built on top of those boost libraries. Also I think it would be more "C++" to use an operator overload <B> >> </B> to show the iterators working like a pipe (similar to the way this is all done in F# as well).Danielhttps://www.blogger.com/profile/11384619047799752406noreply@blogger.comtag:blogger.com,1999:blog-8715120618224381002.post-78662515654940974132009-05-22T18:41:08.051+01:002009-05-22T18:41:08.051+01:00Time to start the opensource project?Time to start the opensource project?Anonymousnoreply@blogger.com