[C++-sig] Re: C arrays solution

Raoul Gough RaoulGough at yahoo.co.uk
Mon Oct 13 11:01:19 CEST 2003

"Niall Douglas" <s_sourceforge at nedprod.com> writes:

> On 12 Oct 2003 at 18:05, Raoul Gough wrote:
>> Not sure if this is how Boost.Python does it, but the Boost
>> type_traits library would be sufficient for what you described
>> above. See the "Function Traits" section of libs/type_traits/index.htm
>> for details.
> Actually this came to me as a sort of epiphany today as I was hauling 
> rigging off a boat - some number of hours later and I have the below, 
> the very first working proof of concept.
> I should also add that the below is my VERY FIRST C++ metaprogram. I 
> failed a job interview for not knowing it, bought Andrei's Modern C++ 
> Design immediately afterwards and have been playing with it on & off 
> since for the last four months. But not until today did I actually 
> ever write something on my own bat not copied from elsewhere. I feel 
> like my very first 1000 line program in BBC Basic nearly two decades 
> ago now!
> Note the below is nasty (especially my choice of non-distinctive 
> naming) and only supports one instance currently. I'm going to need a 
> functor more generic than the boost one in order to store a hash 
> table of functions from which I can correctly invoke translation (you 
> can see the hack I used below to access the function pointers). Thus 
> chances are that my end effort will be compatible with my library, 
> but not yours.
> Thoughts on the below? Is it worth you integrating similar 
> functionality and thus all other bpl users can use it? Or is this too 
> esoteric and/or demanding to warrant inclusion?

I can't really comment on this, because I don't understand what the
code is supposed to do. Can you explain the motivation for it?

I have the feeling that you may be reinventing one or two wheels as
well - e.g. have you considered using std::vector or boost::array, and
what about type_traits? Also, I wonder about the use of member
function pointers - is there an easier way to get what you want?

> static void *carray;
> ...
> carray=(void *) new CArray<getArrayFn, getLenFn>(a, b);

This look pretty suspect to me - what's going on here?

Raoul Gough.
(setq dabbrev-case-fold-search nil)

More information about the Cplusplus-sig mailing list