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
11namespace mpl = boost::mpl;
12namespace proto = boost::proto;
13using proto::_;
14
15template<class E>
16struct e;
17
18struct g
19 : proto::or_<
20 proto::terminal<int>
21 , proto::plus<g,g>
22 >
23{};
24
25struct d
26 : proto::domain<proto::generator<e>, g>
27{};
28
29template<class E>
30struct 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
40e<proto::terminal<int>::type> i;
41
42template<class E>
43std::ostream &operator<<(std::ostream &sout, e<E> const &x)
44{
45 return sout;
46}
47
48int main()
49{
50 std::cout << (i+i);
51}
52

source code of boost/libs/proto/test/bug2407.cpp