Modernize IoComponentEntry (follow up from !646)
The following discussion from !646 (merged) should be addressed:
-
@graven started a discussion: (+1 comment) How about:
struct IoComponentEntry final { std::string m_oldfname; std::string m_oldabspath; std::string m_oldabspath; std::string m_newfname; IIoComponentMgr::IoMode::Type m_iomode = IIoComponentMgr::IoMode::INVALID; IoComponentEntry() = default; IoComponentEntry( std::string f, std::string p, const IIoComponentMgr::IoMode::Type& t ) : m_oldfname( std::move(f) ), m_oldabspath( std::move(p) ), m_iomode( t ) { } friend bool operator<( IoComponentEntry const& lhs, IoComponentEntry const& rhs ) { return std::tie( lhs.m_oldfname, lhs.m_iomode ) < std::tie( rhs.m_oldfname, rhs.m_iomode ); } friend std::ostream& operator<<( std::ostream& os, const IoComponentEntry& c ) { return os << "old: \"" << c.m_oldfname << "\" absolute path: \"" << c.m_oldabspath << "\" new: \"" << c.m_newfname << "\" m: " << ( ( c.m_iomode == IIoComponentMgr::IoMode::READ ) ? "R" : "W" ); } };
Binary comparisons are better done as
friend
, so that they are symmetric wrt. type conversions on lhs and rhs. There is no need for an explicit copy constructor, as the one generated implicitly will do the same thing.