On 07/28/10 09:37, Hite, Christopher wrote:
[snip]
I'm tring to use the template compiler to generate equivalent code.  I
have a mpl::list of packet descriptions like this:
        struct Packet1{
                static const int id=1;
                void decode();
        };

I then use boost::mpl::fold to generate a decode function which might
look sort of like this:

        void decode1(int id){
                if(id==1)
                        Packet1::decode();
else decode2(id);
        }

[snip]
boost::mpl::fold generates types, not functions; hence, I don't
understand how it can be used to generate this function.
Maybe if you posted the code that generates the function or functions
it would be open my eyes.

Also, maybe the proposed boost switch library would be some help:

  http://svn.boost.org/svn/boost/sandbox/switch/

HTH.

-Larry

BTW, I've asked a somewhat similar question about used a
constant vector of function pointers and whether that would
be faster than a switch:

http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/364c0dd5ce512497#

The response was it wouldn't.

Reply via email to