Ticket #3114: parameter_extra_lazy.cpp

File parameter_extra_lazy.cpp, 644 bytes (added by Jeremiah Willcock, 13 years ago)

An example program that fails with zero-argument use of result_of (the old behavior)

Line 
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
7BOOST_PARAMETER_NAME(param);
8
9template <typename T> struct empty {};
10
11struct 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
22int main(int, char**) {
23 (_param = 0)[_param || my_default_computer()];
24 return 0;
25}