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