[proto] extended expressions and assignment operator
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 --
Maurizio Vitale wrote:
Hi Eric,
I'm trying to have proto allow me to do things like:
(a,b,c) = expr;
where a, b, c are integers
Protofied integers, it seems.
of different width
You mean, short, int, long?
and they should be assigned the appropriate slice of expr.
What is expr, and what is a slice of expr?
For instance:
| variable | width | value | |----------+-------+-----------| | a | 2 | expr[6:7] | | b | 4 | expr[2:5] | | c | 2 | expr[0:1] |
I don't understand your syntax.
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. <snip>
I'm afraid you've lost me. I don't know what "this" is. :-( Care to try again? -- Eric Niebler BoostPro Computing http://www.boostpro.com
2009/8/13 Maurizio Vitale
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.
if in ... (a,b,c) = expr; ... a,b,c are of unproxied builtin type, then it might not be possible in C++, as you can not overload operators (in this case 'operator,(lhs,rhs)') upon builtin types only.
"Sebastian" == Sebastian Mach
writes:
Sebastian> 2009/8/13 Maurizio Vitale
Sebastian>
participants (4)
-
Eric Niebler
-
Maurizio Vitale
-
Maurizio Vitale
-
Sebastian Mach