|
Boost : |
From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2003-03-18 07:32:04
On Mon, 17 Mar 2003 08:56:54 -0600, "David B. Held"
<dheld_at_[hidden]> wrote:
>"Gennaro Prota" <gennaro_prota_at_[hidden]> wrote
>> [...]
>> What monster are you creating, man? :-)
>
>I must be the only one here that actually writes application code,
>because it never ceases to amaze me how everyone else can follow
>all these neat and tidy rules for writing "pure" code.
It was just a joke. I don't have any rule that I follow blindly just
because it is considered 'good programming'.
[...]
>> Ok, assuming that you need so much parameters, and that there's
>> a speed gain with using call_traits,
>
>Considering that some of the fields are std::vector<>s, and some
>of them are bools, you tell me. ;)
You have the program to measure, not me :-) Of course I was hinting at
passing the mice by reference rather than the pachyderms by value.
>> [...]
>> foo f(x1, x2, x3, (void(*)(X1, X2, X3))0 );
>
>Clever, but I don't need call_traits<> that badly. ;) I'll just make
>everything a const&.
Cough... cough ... :-)
>If you could take the address of a c'tor, this
>actually might be possible. Consider this code, which illustrates
>what I want to do:
>
>#define PARAM(t) boost::call_traits<t>::param_type
>
>template <typename T>
>class wrapper
>{
> template <typename U1, typename U2, ...>
> wrapper(int v, PARAM(U1) v1, PARAM(U2) v2, ...,
> void (*)(U1, U2, ...) = &T::T)
> : value_added_member_(v), data(v1, v2, ...) { }
>private:
> int value_added_member_;
> T data_;
>};
>
>Unfortunately, &T::T isn't allowed. I understand why (sort of), but
>it might actually make your trick be useful (or maybe not, I don't
>know).
Not much, as you couldn't deduce T's constructor parameter types
anyway. I assumed the null pointer expression to be used in the
initializer for the "most external constructor" (wrapper::wrapper). As
I said about the other version, based on pointer-to-objects, that
expression has a role (and a form) similar to an explicit <
template-argument-list >, and has about the same limitations: you must
know what are the types to put in the list at the point where you
select the constructor.
BTW, the following paper (which probably you know)
http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm
has a nice discussion related to what you are doing.
Genny.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk