Created
August 15, 2010 18:18
-
-
Save anonymous/525778 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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