Re: a simple question

Posted by DU VIGNAUD DE VILLEFORT FRANCOIS GASAPRD PHI on
URL: http://quantlib.414.s1.nabble.com/a-simple-question-tp9462p9465.html

>As for QL_NULL_REAL, it doesn't really matter what value is used as long as >it's a determined one

Since it is now used as some kind of unitialized value by the quotes classes, I would say that it is no longer such an immaterial detail. For example if we can encounter the following problem:

        SimpleQuote quote;
        Real value = (std::numeric_limits<float>::max)(); //limit case test
        Quote.setValue(value);
        //a few lines of code later ... bug !!!!

>Speaking of which, funny that you came out with a question on Null. Just
>yesterday I was thinking of removing it and using boost::optional when a
>number might or might not be defined. What do you think?

Maybe you have thought about boost::optional for the same reason. ;-)
It would be cleaner indeed. However I'm not convinced that it's a good solution yet.
IMO boost::optional a pefect solution in the case of a free function which can return invalid result even in normal situations. (like the second example of boost optional tutorial).

On the hand it seems to me that using it for a function member would add some spurious trickyness to the class. What do you think of this implementation ?

        Quote():isValid_(false){}

        virtual void resetQuote() {
            isValid_ = false;
        }

        virtual bool isValid() const {
            return isValid_;
        };
        private:
        bool isValid_;


regards,

François

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev