Boost logo

Boost :

From: E. Gladyshev (eegg_at_[hidden])
Date: 2004-11-16 04:17:24


Rene Rivera wrote:
[...]
>
> I don't remember there being a requirement to use macros on this
> named_params library. And I showed how to do exactly that, wrap C style
> function, in my example (in my review) without macros.

 From the library docs, my impression was that macros
is the recommended way to go.

[...]
>
> It may be "fun", but the overhead is overwhelming. I find this
> alternative more appealing...
>
> namespace {
> boost::keyword<struct title_t> title;
> boost::keyword<struct style_t> style;
> }
> struct widget {
> widget() { }
>
> int create( const char * title, int style );
>
> template<class Params>
> inline int create(const Params & params) {
> return create(params[title], params[style | int(45));
> }
> };
> int main() {
> widget w;
> w.create((title = "my widget));
> return 0;
> }
>
> Especially considering that the overhead is *zero* with release
> optimizations. And you can also do the more normal construction by adding:
>
> template<class Params>
> widget(const Params& params) {
> create(params[title], params[style | int(45));
> }
>
> I fail to see how the functor gives you anything here. Perhaps you need
> a better counter example?
>

Well,
namespace {
     boost::keyword<struct title_t> title;
     boost::keyword<struct style_t> style;
}
is not very pretty.

I don't know how to make a better counter example.
Your example is just completely different from mine.
You create a normal wrapper, I create a functor (well sort of).
It is a standard stuff (function pointers and functions)...
It is like saying give me a good counter example
as to why a function pointer is better than a function. :)
So I am not sure what do I have to counter.

Eugene


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk