<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">I found a strange error when I try the vec3 sample from proto, my code is like this:<br><br>struct Vec3SubscriptCtx<br> : proto::callable_context< Vec3SubscriptCtx const ><br>{<br> typedef int result_type;<br><br> Vec3SubscriptCtx(int i)<br> : i_(i)<br> {}<br><br> // Index array terminals with our subscript. Everything<br> // else will be handled by the default evaluation context.<br> int operator ()(proto::tag::terminal, int const (&arr)[3]) const<br> {<br> return arr[this->i_];<br> }<br><br> int i_;<br>};<br>struct Vec3<br> : proto::extends<proto::terminal<int[3]>::type, Vec3><br>{<br> explicit Vec3(int i=0, int j=0, int k=0)<br> {<br> (*this)[0] = i;<br> (*this)[1] = j;<br> (*this)[2] = k;<br> }<br><br> int &operator [](int i)<br> {<br> return proto::value(*this)[i];<br> }<br><br> int const &operator [](int i) const<br> {<br> return proto::value(*this)[i];<br> }<br><br> // Here we define a operator = for Vec3 terminals that<br> // takes a Vec3 expression.<br> template< typename Expr ><br> Vec3 &operator =(Expr const & expr)<br> {<br> typedef Vec3SubscriptCtx const CVec3SubscriptCtx;<br> (*this)[0] = proto::eval(proto::as_expr(expr), CVec3SubscriptCtx(0));<br> (*this)[1] = proto::eval(proto::as_expr(expr), CVec3SubscriptCtx(1));<br> (*this)[2] = proto::eval(proto::as_expr(expr), CVec3SubscriptCtx(2));<br> return *this;<br> }<br><br> template< typename Expr ><br> Vec3 (Expr const & expr)<br> {<br> typedef Vec3SubscriptCtx const CVec3SubscriptCtx;<br> (*this)[0] = proto::eval(proto::as_expr(expr), CVec3SubscriptCtx(0));<br> (*this)[1] = proto::eval(proto::as_expr(expr), CVec3SubscriptCtx(1));<br> (*this)[2] = proto::eval(proto::as_expr(expr), CVec3SubscriptCtx(2)); <br> }<br><br> void print() const<br> {<br> std::cout << '{' << (*this)[0]<br> << ", " << (*this)[1]<br> << ", " << (*this)[2]<br> << '}' << std::endl;<br> }<br>};<br>int main(int argc, const char* argv[])<br>{<br> Vec3 a(1, 2, 3);<br> Vec3 b(3, 2, 1);<br> Vec3 c;<br> c = b; <br> c.print();<br><br> return 0;<br>}<br><br>I expected that when c is printed it will display 3, 2, 1 ( the value of b ) but instead it print 0,0,0 like b is never assigned to c. I try this using vs 2010 with boost 1.44 in windows 7 64.<br></td></tr></table><br>