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