1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // bug2407.hpp |
3 | // |
4 | // Copyright 2008 Eric Niebler. Distributed under the Boost |
5 | // Software License, Version 1.0. (See accompanying file |
6 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
7 | |
8 | #include <iostream> |
9 | #include <boost/proto/proto.hpp> |
10 | |
11 | namespace mpl = boost::mpl; |
12 | namespace proto = boost::proto; |
13 | using proto::_; |
14 | |
15 | template<class E> |
16 | struct e; |
17 | |
18 | struct g |
19 | : proto::or_< |
20 | proto::terminal<int> |
21 | , proto::plus<g,g> |
22 | > |
23 | {}; |
24 | |
25 | struct d |
26 | : proto::domain<proto::generator<e>, g> |
27 | {}; |
28 | |
29 | template<class E> |
30 | struct e |
31 | : proto::extends<E, e<E>, d> |
32 | { |
33 | BOOST_MPL_ASSERT((proto::matches<E, g>)); |
34 | |
35 | e(E const &x = E()) |
36 | : proto::extends<E, e<E>, d>(x) |
37 | {} |
38 | }; |
39 | |
40 | e<proto::terminal<int>::type> i; |
41 | |
42 | template<class E> |
43 | std::ostream &operator<<(std::ostream &sout, e<E> const &x) |
44 | { |
45 | return sout; |
46 | } |
47 | |
48 | int main() |
49 | { |
50 | std::cout << (i+i); |
51 | } |
52 | |