Ticket #4910: display_expr-66440.2.patch
File display_expr-66440.2.patch, 3.1 KB (added by , 12 years ago) |
---|
-
./boost/proto/debug.hpp
83 83 84 84 namespace hidden_detail_ 85 85 { 86 struct ostream_wrapper 87 { 88 ostream_wrapper(std::ostream &sout) 89 : sout_(sout) 90 {} 91 92 std::ostream &sout_; 93 }; 94 95 template<typename Tag> 96 std::ostream &operator <<(ostream_wrapper sout_wrap, Tag const &) 97 { 98 return sout_wrap.sout_ << BOOST_SP_TYPEID(Tag).name(); 99 } 86 // has_ostream_shift trait 87 struct yes_type { char x; }; 88 struct no_type { yes_type x[2]; }; 89 90 template<typename T> T fake(); 91 92 no_type has_ostream_shift_test(...); 93 94 template<typename T> 95 typename boost::enable_if_c< sizeof( fake<std::ostream&>() << fake<const T&>() ) 96 , yes_type >::type 97 has_ostream_shift_test(const T&); 98 99 template<typename T> 100 struct has_ostream_shift 101 : boost::mpl::bool_< 102 sizeof( has_ostream_shift_test(fake<const T&>()) ) == sizeof( yes_type ) 103 > 104 {}; 105 106 // output 107 template<typename T> inline 108 void output_impl( std::ostream& os, const T& x, boost::mpl::true_ ) 109 { 110 os << x; 111 } 112 113 template<typename T> inline 114 void output_impl( std::ostream& os, const T& x, boost::mpl::false_ ) 115 { 116 os << typeid(T).name(); 117 } 118 119 template<typename T> inline 120 void output( std::ostream& os, const T& x ) 121 { 122 output_impl( os, x, has_ostream_shift<T>() ); 123 } 100 124 } 101 125 102 126 namespace functional … … 138 162 template<typename Expr> 139 163 void impl(Expr const &expr, mpl::long_<0>) const 140 164 { 141 using namespace hidden_detail_;142 165 typedef typename tag_of<Expr>::type tag; 143 166 this->sout_.width(this->depth_); 144 167 this->sout_ << (this->first_? "" : ", "); 145 this->sout_ << tag() << "(" << proto::value(expr) << ")\n"; 168 hidden_detail_::out( this->sout_, tag() ); 169 this->sout_ << "("; 170 hidden_detail_::out( this->sout_, proto::value(expr) ); 171 this->sout_ << ")\n"; 146 172 this->first_ = false; 147 173 } 148 174 149 175 template<typename Expr, typename Arity> 150 176 void impl(Expr const &expr, Arity) const 151 177 { 152 using namespace hidden_detail_;153 178 typedef typename tag_of<Expr>::type tag; 154 179 this->sout_.width(this->depth_); 155 180 this->sout_ << (this->first_? "" : ", "); 156 this->sout_ << tag() << "(\n"; 181 hidden_detail_::out( this->sout_, tag() ); 182 this->sout_ << "(\n"; 157 183 display_expr display(this->sout_, this->depth_ + 4); 158 184 fusion::for_each(expr, display); 159 185 this->sout_.width(this->depth_);