Ticket #4910: display_expr-1.44.0.patch
File display_expr-1.44.0.patch, 2.8 KB (added by , 12 years ago) |
---|
-
boost/proto/
old new 84 84 85 85 namespace hidden_detail_ 86 86 { 87 struct ostream_wrapper 88 { 89 ostream_wrapper(std::ostream &sout) 90 : sout_(sout) 91 {} 87 struct yes_type { char x; }; 88 struct no_type { yes_type x[2]; }; 92 89 93 std::ostream &sout_; 94 }; 90 no_type has_ostream_shift(...); 95 91 96 template<typename Tag> 97 std::ostream &operator <<(ostream_wrapper sout_wrap, Tag const &) 98 { 99 return sout_wrap.sout_ << typeid(Tag).name(); 100 } 92 template<class T> 93 typename boost::enable_if_c< 94 sizeof(*(std::ostream*)NULL << *(T*)NULL) 95 , yes_type >::type 96 has_ostream_shift(const T&); 97 98 template<bool has> 99 struct Out 100 { 101 template<class T> static void out( std::ostream& os, const T& x ); 102 }; 103 104 template<> template<class T> inline 105 void Out<true>::out( std::ostream& os, const T& x ) 106 { 107 os << x; 108 } 109 110 template<> template<class T> inline 111 void Out<false>::out( std::ostream& os, const T& x ) 112 { 113 os << typeid(T).name(); 114 } 115 116 template<class T> inline 117 void out( std::ostream& os, const T& x ) 118 { 119 Out< sizeof(has_ostream_shift(*(T*)NULL)) == sizeof(yes_type) >::out( os, x ); 120 } 101 121 } 102 103 122 namespace functional 104 123 { 105 124 /// \brief Pretty-print a Proto expression tree. … … 139 158 template<typename Expr> 140 159 void impl(Expr const &expr, mpl::long_<0>) const 141 160 { 142 using namespace hidden_detail_;143 161 typedef typename tag_of<Expr>::type tag; 144 162 this->sout_ << std::setw(this->depth_) << (this->first_? "" : ", "); 145 this->sout_ << tag() << "(" << proto::value(expr) << ")\n"; 163 hidden_detail_::out( this->sout_, tag() ); 164 this->sout_ << "("; 165 hidden_detail_::out( this->sout_, proto::value(expr) ); 166 this->sout_ << ")\n"; 146 167 this->first_ = false; 147 168 } 148 169 149 170 template<typename Expr, typename Arity> 150 171 void impl(Expr const &expr, Arity) const 151 172 { 152 using namespace hidden_detail_;153 173 typedef typename tag_of<Expr>::type tag; 154 174 this->sout_ << std::setw(this->depth_) << (this->first_? "" : ", "); 155 this->sout_ << tag() << "(\n"; 175 hidden_detail_::out( this->sout_, tag() ); 176 this->sout_ << "(\n"; 156 177 display_expr display(this->sout_, this->depth_ + 4); 157 178 fusion::for_each(expr, display); 158 179 this->sout_ << std::setw(this->depth_) << "" << ")\n";