Feature #306
Function for accessing the pointed value
Description
We have many arguments like
...(intrusive_ptr_cast<BigIntValue>(v)->theInteger)... ...(intrusive_ptr_cast<RingElemValue>(v)->theRingElem)...
where v is a intrusive_ptr<RightValue>
I think we should have a function returning "the actual value".
As I cannot see very far I suggest, at least to start with, one function per type (making it easier to control the types)
instead of a very abstract function (opening the road for a more automatic way of "CoCoA-5 oveloading").
Example:
RingElem& theRingElem(const intrusive_ptr<RightValue>& v) { return intrusive_ptr_cast<RingElemValue>(v)->theRingElem; }
would that work? any suggestion for a better name?
AMB 2013-02-13 it works and is called, for the time being, PtrCastRingElem
Related issues
History
#1
Updated by Anna Maria Bigatti over 11 years ago
- Category set to Parser/Interpreter
- Target version set to CoCoA-5.0.9
#2
Updated by John Abbott over 11 years ago
JAA likes the proposal; cannot see any obvious objection (I wonder if the compiler will).
Other possible names: GetRingElem
, AsRingElem
.
#3
Updated by Anna Maria Bigatti over 11 years ago
- Status changed from New to In Progress
- Assignee set to Anna Maria Bigatti
Too many new functions for modules: I think I'd better start experimenting with this "shortcut" ;-)
I'll try the name CastPtrRingElem: easy to find and replace...
But what is the difference between these two?
boost::dynamic_pointer_cast<const RingElemValue> intrusive_ptr_cast<RingElemValue>
??
#4
Updated by Anna Maria Bigatti over 11 years ago
Implemented: seems to work fine. Example (in BuiltinFunctions.H)
inline const BigInt& PtrCastBigInt(boost::intrusive_ptr<const RightValue> x) { return intrusive_ptr_cast<const BigIntValue>(x)->theInteger; }
... I admit I never know when problems with temporaries might arise, but I'm confident that it would crash on my tests if this were the case ;-)
#5
Updated by Anna Maria Bigatti over 11 years ago
- Target version changed from CoCoA-5.0.9 to CoCoA-5.0.3
- % Done changed from 0 to 50
#6
Updated by Anna Maria Bigatti about 11 years ago
- Target version changed from CoCoA-5.0.3 to CoCoA-5.0.9
#7
Updated by Anna Maria Bigatti over 10 years ago
- Status changed from In Progress to Feedback
- Priority changed from Normal to High
- % Done changed from 50 to 90
I think it looks pretty nice now. I even wrote a bit of documentation.
Feedback.
#8
Updated by Anna Maria Bigatti over 10 years ago
- Status changed from Feedback to Closed
- % Done changed from 90 to 100
No problems have arisen. Closing.