bug2407.cpp 946 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. #include <iostream>
  8. #include <boost/proto/proto.hpp>
  9. namespace mpl = boost::mpl;
  10. namespace proto = boost::proto;
  11. using proto::_;
  12. template<class E>
  13. struct e;
  14. struct g
  15. : proto::or_<
  16. proto::terminal<int>
  17. , proto::plus<g,g>
  18. >
  19. {};
  20. struct d
  21. : proto::domain<proto::generator<e>, g>
  22. {};
  23. template<class E>
  24. struct e
  25. : proto::extends<E, e<E>, d>
  26. {
  27. BOOST_MPL_ASSERT((proto::matches<E, g>));
  28. e(E const &x = E())
  29. : proto::extends<E, e<E>, d>(x)
  30. {}
  31. };
  32. e<proto::terminal<int>::type> i;
  33. template<class E>
  34. std::ostream &operator<<(std::ostream &sout, e<E> const &x)
  35. {
  36. return sout;
  37. }
  38. int main()
  39. {
  40. std::cout << (i+i);
  41. }