Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Created August 15, 2010 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/525778 to your computer and use it in GitHub Desktop.
Save anonymous/525778 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <boost/parameter.hpp>
BOOST_PARAMETER_NAME(speed);
BOOST_PARAMETER_NAME(force);
BOOST_PARAMETER_NAME(bar);
struct foo
{
template <typename ParamMap>
foo( ParamMap const& opt )
: speed_( opt[_speed] )
, force_( opt[_force] )
, bar_( opt[_bar | true] )
{}
float speed_;
int force_;
bool bar_;
};
using namespace std;
int main()
{
{
foo f((_speed = 8.9f, _bar= false, _force = 5));
cout << f.speed_ << " " << f.force_ << " " << f.bar_ << "\n";
}
{
foo f((_speed = 8.9f, _force = 5));
cout << f.speed_ << " " << f.force_ << " " << f.bar_ << "\n";
}
{
// uncomment this to get an error
//baz b(options[speed = 9.9f, force = 5]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment