| 1 | #include <iostream>
|
|---|
| 2 |
|
|---|
| 3 | #include <boost/parameter.hpp>
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 | BOOST_PARAMETER_NAME(name)
|
|---|
| 7 | BOOST_PARAMETER_NAME(index)
|
|---|
| 8 |
|
|---|
| 9 | struct myclass_impl
|
|---|
| 10 | {
|
|---|
| 11 | template <class ArgumentPack>
|
|---|
| 12 | myclass_impl(ArgumentPack const& args)
|
|---|
| 13 | {
|
|---|
| 14 | std::cout << "name = " << args[_name]
|
|---|
| 15 | << "; index = " << args[_index]
|
|---|
| 16 | << std::endl;
|
|---|
| 17 | }
|
|---|
| 18 | };
|
|---|
| 19 |
|
|---|
| 20 | struct myclass : myclass_impl
|
|---|
| 21 | {
|
|---|
| 22 | BOOST_PARAMETER_CONSTRUCTOR(
|
|---|
| 23 | myclass, (myclass_impl), tag
|
|---|
| 24 | , (optional (name, *) (index, *)
|
|---|
| 25 | )
|
|---|
| 26 | ) // no semicolon
|
|---|
| 27 | };
|
|---|
| 28 |
|
|---|
| 29 | int main(int argc, char * argv[])
|
|---|
| 30 | {
|
|---|
| 31 | myclass C(_name="hello", _index=0);
|
|---|
| 32 | }
|
|---|