how to structure code that uses std::rel_ops
- by R Samuel Klatchko
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?