1 | // This is a silly example, but it demonstrates that the type of a lazy default
|
---|
2 | // probably should not be evaluated when the parameter is given explicitly
|
---|
3 | // (since the type of the default is never needed in that case).
|
---|
4 |
|
---|
5 | #include <boost/parameter.hpp>
|
---|
6 |
|
---|
7 | BOOST_PARAMETER_NAME(param);
|
---|
8 |
|
---|
9 | template <typename T> struct empty {};
|
---|
10 |
|
---|
11 | struct my_default_computer {
|
---|
12 | #if 0
|
---|
13 | // What I need to do now (broken):
|
---|
14 | typedef empty<int>::type result_type;
|
---|
15 | #else
|
---|
16 | // What I want to do:
|
---|
17 | template <typename T>
|
---|
18 | struct result {typedef typename empty<T>::type type;};
|
---|
19 | #endif
|
---|
20 | };
|
---|
21 |
|
---|
22 | int main(int, char**) {
|
---|
23 | (_param = 0)[_param || my_default_computer()];
|
---|
24 | return 0;
|
---|
25 | }
|
---|