E
Eternally
Hey folks,
To me, this sounds like a crazy question, but I'll throw it out there
anyway.
Is it possible to change a variables data type half way through a running
program? If so, how?
You're probably thinking why would you ever want to do that. Valid
question. If you're curious why I'd like to do it, read on. But otherwise,
you can stop here and just answer if it's possible.
I've got an Expression Template program. As you probably know, an
expression variable has as it's data type, the data types of all the nodes
and leaves that make up it's parse tree.
So, the expression (x+y) + z would have a data type similar to the following
(depending on how you set up your program of course):
DExpr< DBinExprOp<DExpr< DBinExprOp<DExpr<int>, DExpr<int>, DApAdd> >,
DExpr<int>, DApAdd> >
What I'd like to do is merge two expression's parse trees into one and store
the newly merged parse tree in one of the original trees variables.
So if I have:
myExpr1((x+y) + z);
myExpr2(a + b);
myExpr1 = (myExpr1 + myExpr2);
In this example, the original myExpr1 would have the data type
DExpr< DBinExprOp<DExpr< DBinExprOp<DExpr<int>, DExpr<int>, DApAdd> >,
DExpr<int>, DApAdd> >
myExpr2 would have the data type
DExpr< DBinExprOp<DExpr<int>, DExpr<int>, DApAdd> >
And the merged tree would have the data type
DExpr< DBinExprOp< DExpr<DBinExprOp<DExpr< DBinExprOp<DExpr<int>,
DExpr<int>, DApAdd> >, DExpr<int>, DApAdd> >, DExpr<DBinExprOp<DExpr<int>,
DExpr<int>, DApAdd> > >
But, for this to work, it would essentially mean changing myExpr1's data
type from it's original to the new one above.
Impossible, right?
I was thinking if it were possible the only way would be to create
amyExprTemp which holds the new tree,
Thanks a lot!
To me, this sounds like a crazy question, but I'll throw it out there
anyway.
Is it possible to change a variables data type half way through a running
program? If so, how?
You're probably thinking why would you ever want to do that. Valid
question. If you're curious why I'd like to do it, read on. But otherwise,
you can stop here and just answer if it's possible.
I've got an Expression Template program. As you probably know, an
expression variable has as it's data type, the data types of all the nodes
and leaves that make up it's parse tree.
So, the expression (x+y) + z would have a data type similar to the following
(depending on how you set up your program of course):
DExpr< DBinExprOp<DExpr< DBinExprOp<DExpr<int>, DExpr<int>, DApAdd> >,
DExpr<int>, DApAdd> >
What I'd like to do is merge two expression's parse trees into one and store
the newly merged parse tree in one of the original trees variables.
So if I have:
myExpr1((x+y) + z);
myExpr2(a + b);
myExpr1 = (myExpr1 + myExpr2);
In this example, the original myExpr1 would have the data type
DExpr< DBinExprOp<DExpr< DBinExprOp<DExpr<int>, DExpr<int>, DApAdd> >,
DExpr<int>, DApAdd> >
myExpr2 would have the data type
DExpr< DBinExprOp<DExpr<int>, DExpr<int>, DApAdd> >
And the merged tree would have the data type
DExpr< DBinExprOp< DExpr<DBinExprOp<DExpr< DBinExprOp<DExpr<int>,
DExpr<int>, DApAdd> >, DExpr<int>, DApAdd> >, DExpr<DBinExprOp<DExpr<int>,
DExpr<int>, DApAdd> > >
But, for this to work, it would essentially mean changing myExpr1's data
type from it's original to the new one above.
Impossible, right?
I was thinking if it were possible the only way would be to create
amyExprTemp which holds the new tree,
Thanks a lot!