how to structure code that uses std::rel_ops
        Posted  
        
            by R Samuel Klatchko
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by R Samuel Klatchko
        
        
        
        Published on 2010-06-14T05:29:39Z
        Indexed on 
            2010/06/14
            5:32 UTC
        
        
        Read the original article
        Hit count: 263
        
I was working on some code and wanted to make use of std::rel_ops.  From what I can tell, you need to do using std::rel_ops to your source code to make use of them.  But I'm not sure where the best place to put that is.
Let's say I have a header file with a class that only defines the minimal operator== and operator<:
// foo.h
class foo
{
public:
    bool operator==(const foo &other) const;
    bool operator<(const foo &other) const;
};
I'm not sure where to put using std::rel_ops.  If I leave it out of the foo.h, then every user of foo.h needs to know the implementation detail that foo is not defining all the operators itself.
But putting using std::rel_ops inside foo.h breaks the rule of thumb about not having a using in a header file.
How do other people resolve this issue?
© Stack Overflow or respective owner