Boost logo

Boost Users :

Subject: [Boost-users] [proto] extended expressions and assignment operator
From: Maurizio Vitale (mav_at_[hidden])
Date: 2009-08-13 14:49:45


Hi Eric,

  I'm trying to have proto allow me to do things like:

(a,b,c) = expr;

where a, b, c are integers of different width and they should be
assigned the appropriate slice of expr. For instance:

| variable | width | value |
|----------+-------+-----------|
| a | 2 | expr[6:7] |
| b | 4 | expr[2:5] |
| c | 2 | expr[0:1] |

width are compile-time constants and I need to keep them so (they'll be
used to compute masks and shifts at compile time).

First problem is that I do not know of a good way for doing this. As
you'll see in the code attached, right now I'm using fusion::fold and
proto::flatten, but this does the width part at run-time (in the example
I'm using sizeof () instead of real widths to keep things simple).

The second problem is that operator= needs to be const. I think I've an
idea of why, but I'd appreciate if you could tell me. Assuming this is
what it should be, is it safe to cast away the constness in struct
assign?

Last question, I've seen in some of your examples that you explicitly
disable all assignment operators. It doesn't seem to make a difference
here. What is the story?

Thanks a lot in advance,

   Maurizio



-- 


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net