public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Larry Evans <cppljevans@suddenlink.net>
To: gcc@gcc.gnu.org
Subject: Re: optimization question: mpl
Date: Wed, 28 Jul 2010 15:35:00 -0000	[thread overview]
Message-ID: <i2pimp$gae$1@dough.gmane.org> (raw)
In-Reply-To: <824586E7387D1443B5DD024DAC75B91C139048@SE000319.ztb.icb.commerzbank.com>

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.

      parent reply	other threads:[~2010-07-28 15:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-28 14:38 Hite, Christopher
2010-07-28 15:26 ` Richard Guenther
2010-07-28 15:53   ` Hite, Christopher
2010-07-28 17:26     ` Larry Evans
2010-07-28 18:17     ` Piotr Rak
2010-07-28 19:00       ` Larry Evans
2011-10-17 16:35       ` Hite, Christopher
2010-07-29 12:16   ` Larry Evans
2010-07-28 15:35 ` Larry Evans [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='i2pimp$gae$1@dough.gmane.org' \
    --to=cppljevans@suddenlink.net \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).