November 25th, 2011, 1:17 pm
QuoteOriginally posted by: outrunQuoteOriginally posted by: CuchulainnQuoteOriginally posted by: outrunthanks!I'm not sure if this is correct, but here is an idea I had:I've quite often used "std::sort" "std::map" etc with my own user-defined compare like below. Could you do the same for the f() in your example and eliminate the need of boost::function?Not sure what this means, exactly.It could be possible but why would you want to eiminate the need for boost function? it is a *protocol* and already subsumes any kind of function you throw at it. You can define any comparitor and use it to instantiate the boost function. It is the same as .NET delegate type vs delegate instance.Do you want to make the s/w so generic that even boost function has been templated away? If so, then the code will be very difficult to understand.The core issue is that we want to get away from GOF Observer.I don't see it as "so generic that even..". The example I gave is not complicated is it, is simple plain C++, nothing fancy, no effort, right..? Anyone can use std::sort without having to install, use (and learn) boos::function. To me that is a benefit towards users of my code. So It's an honest question.I write two types of code:1) Application that perform tasks. For those I use boost.2) generic code / modules / libraries. For those I don't want to force dependency on boost unless is has a very obvious benefit (like not having to implement things have already been done in boost).I think you are in 1) and I in 2) when we talk about QFCL, and QFCL is both, because it has many levels. We had a discussion like this before, right? E.g. the container bindings is also an attempt of me to remove explicit dependencies of 3rd party -or self introduced- containers. That's the same thing...but let's stick to the purpose of you demo "The core issue is that we want to get away from GOF Observer", ..which is what you've demonstrated with your code Yes, very good. I am a library user.Actually, IMHO boost function should be in C++ 11. Functional programming is so useful in this context. QuoteAnyone can use std::sort without having to install, use (and learn) boos::function. To me that is a benefit towards users of my code. So It's an honest question.I see it takes people 10 minutes to learn function After that they apply it and that is ongoing.QuoteThe example I gave is not complicated is it, is simple plain C++, nothing fancy, no effort, right..? sort() is special case. Things become more tricky with other STL algorithms, e.g. inner_product.
Last edited by
Cuchulainn on November 24th, 2011, 11:00 pm, edited 1 time in total.