Boilerplate generated code

I have a class that mostly remains the same except for the variables and functions to retrieve the variables. I've looked at boost preprocessor and it seems more designed to create classes that have a fixed number of variables but different defaults. Could any of the boost libraries turn the included class into boilerplate code that allows an arbitrary number of variables? The example below only has three variables but I could have used any number. Ryan //Minimal detail. Not complete class struct Arguments { Arguments(void) { xxx = false; yyy = 3; zzz = 4530; } bool operator== (Arugments const& rhs) { return ( (xxx == rhs.xxx) && (yyy == rhs.yyy) && (zzz == rhs.zzz)); } bool getXXX(void) const { return xxx; } int getYYY(void) const { return yyy; } long getZZZ(void) const { return zzz; } bool xxx; int yyy; long zzz; }; //Would like to be able to call it instead something like this Create( Arguments, //Class name ((bool, xxx, getXXX, false), (int, yyy, getYYY, 3), (long, zzz, getZZZ, 4530)));

On Fri, Sep 3, 2010 at 8:46 PM, Ryan McConnehey
I have a class that mostly remains the same except for the variables and functions to retrieve the variables. I've looked at boost preprocessor and it seems more designed to create classes that have a fixed number of variables but different defaults. Could any of the boost libraries turn the included class into boilerplate code that allows an arbitrary number of variables? The example below only has three variables but I could have used any number.
<snip> Your example looks like a perfect use for Boost.Preprocessor. Have you read through http://www.boostpro.com/tmpbook/preprocessor.html ? -- Dave Abrahams BoostPro Computing http://www.boostpro.com

Dave Abrahams wrote:
Your example looks like a perfect use for Boost.Preprocessor. Have you read through http://www.boostpro.com/tmpbook/preprocessor.html ?
I did look at the Preprocessor tutorial but didn't think it would do what I needed. I take another look and make sure I fully understand what it can do. Does the Parameter library use the Preprocessor library? Ryan

On Saturday, September 4, 2010, Ryan McConnehey
. Does the Parameter library use the Preprocessor library?
Yep! -- Dave Abrahams BoostPro Computing http://www.boostpro.com
participants (2)
-
Dave Abrahams
-
Ryan McConnehey