Topic: STL's operators template<>bool operator<(...) hurt!!!!!!!!!


Author: vandevod@cs.rpi.edu (David Vandevoorde)
Date: 1996/04/10
Raw View
>>>>> "OP" == O Petrova <opetrova@blue.weeg.uiowa.edu> writes:
[...]
OP> class EExpression
OP>     {
OP>     public:
OP>             EExpression( int );
OP>             EExpression( double );
OP>     public:
OP>       friend EExpression operator+(const EExpression&, const EExpression&);
OP>       friend EExpression operator<(const EExpression&, const EExpression&);
OP>     .....
OP>     public:
OP>              string fSQLString;
OP>     };

OP> void main()
OP>     {
OP>    // Works fine w/o STL, doesn't with it
OP>    // because of template<class T> bool operator> in function.h
OP>    //                              ^^^^
OP>     EExpression a = EExpression( 2 ) > 4;
OP>     ....
OP>     }

OP> I don't like that at all. I think that those operators should be
OP> removed form STL.

Your prayers have been heard... almost ;^)

The relational operator templates of the standard library have been moved
to their own subnamespace (::std::rel_ops, I believe --- not sure). This
is the only case of a standard sub-::std namespace (no pun intended :).

This makes it easy to avoid the problem above (if you have a sufficiently
close implementation that is).

 Daveed
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]





Author: opetrova@blue.weeg.uiowa.edu (O. Petrova)
Date: 1996/04/08
Raw View
[Moderator's note: please note that this article is crossposted to
comp.lang.c++.moderated and comp.std.c++, and that default followups
have been set to comp.std.c++.  mha]

class EExpression
    {
    public:
            EExpression( int );
            EExpression( double );

    public:
      friend EExpression  operator+( const EExpression&, const EExpression& );
      friend EExpression  operator<( const EExpression&, const EExpression& );
    .....
    public:
             string fSQLString;
    };


void main()
    {
   // Works fine w/o STL, doesn't with it
   // because of template<class T> bool operator> in function.h
   //                              ^^^^
    EExpression a = EExpression( 2 ) > 4;
    ....
    }

I don't like that at all. I think that those operators should be
removed form STL.

      [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
      [  Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm  ]
      [  Moderation policy: http://www.connobj.com/cpp/guide.htm  ]
      [      Comments? mailto:c++-request@netlab.cs.rpi.edu       ]
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]