见下列代码,虽然可以做到,但是感觉很丑陋,有更好的办法吗?
class Test
{
public (const std::string & id, const std::string & name)
: mId(id)
, mName(name)
{}
bool operator < (const Test & rhs) const
{
return this->mId < rhs.mId;
}
bool operator == (const Test & rhs) const
{
return this->mId == rhs.mId;
}
std::string mId;
std::string mName;
}
std::set<Test> t;
auto it = t.find(std::string("12345"));
if (it != t.end())
{
it->mName = "ffff"; // 这样不行,
auto t1 = (Test *)&(*it);
t1->mName = "ffff"; // 这样可以,但是感觉太丑陋了
}
--
FROM 13.57.85.*