Files
libattributes/examples/demo.cpp
Jens Luedicke db168ca56e Rewrite.
Simplified namespace nesting.
Refactor virtual setter method name.
2011-01-22 01:30:30 +01:00

32 lines
448 B
C++

#include "settable.hpp"
#include <iostream>
#include <boost/lexical_cast.hpp>
namespace string2type {
template<>
int convert<int>(const std::string &value) {
return boost::lexical_cast<int>(value);
}
}
struct foo : settable::settable {
foo() {
register_setter<int>("x", &x);
}
int x;
};
int main(int argc, char *argv) {
foo f;
f.set_attribute("x", "42");
std::cout << f.x << std::endl;
return 0;
}