On Thu, 27 Mar 2003 14:01:12 -0500, [EMAIL PROTECTED] wrote:

>> -----Original Message-----
>> From: Jan Langer [mailto:[EMAIL PROTECTED]
>
>Just one other thing - instead of:
>  enum result { minus, zero, plus };
>I would do:
>  enum result { minus = -1, zero, plus };
>just for the sake of code readability and ease of understanding.  It doesn't
>change the logic at all.

Well, if we are really going to discuss such quibbles, I would also
change "zero" to "equiv" because that's the usual "term" used for
strict weak ordering. And I would avoid constructs like

    template <typename T>
    compare (T const &a, T const &b)
         : v_ (compare () (a, b).v_)  // <--
     {}

by doing, for instance,

    class compare
    {
        enum result { minus, equiv, plus };
        result v_;

        template <typename T>
        static result do_compare(const T& a, const T& b) {

            if (a < b) return minus;
            else if (b < a) return plus;

            return equiv;
        }

    public:

        compare () : v_ (equiv) {}

        template <typename T>
        compare (T const &a, T const &b)
        : v_ (do_compare(a, b))
        {}

        ....

        template <typename T>
        compare &operator () (T const &a, T const &b)
        {
            if (v_ == equiv)
                do_compare(a, b);

            return *this;
        }

        ....

};


But there are more important points I think; first of all this: if all
I can see "from the outside" is whether v_== minus [note: this is
'plus' in the original code] why keeping three states internally?


Genny.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to