如何测试是否找到了 boost::bimap "right.find" 的结果?

How do I test if the result from boost::bimap "right.find" was found or not?

我刚开始使用 boost::bimap 如果这听起来像是一个基本问题,请原谅我。我正在使用 boost 1.75.0.

看这段代码:

if (rBiMapStudentItemDescBefore.right.count(aryStrStudentItemDesc[i]) > 0)
{
    auto it = rBiMapStudentItemDescBefore.right.find(aryStrStudentItemDesc[i]);
    CString strNewStudentItemDesc = rBiMapStudentItemDescAfter.left.find(it->second)->second;
    pEntry->SetStudentAssignmentType(static_cast<StudentAssign>(i), strNewStudentItemDesc);
}

它工作正常。从我发现的文档或示例中,我不清楚是否可以取消 right.count 调用并简单地测试 it 的 return 值,如下所示:

if (it)
{

}

不喜欢。如何测试是否找到了 right.find 的结果?抱歉,如果我在文档中遗漏了这一点。

我仍然找不到实际的文档,但我想我有:

auto it = rBiMapStudentItemDescBefore.right.find(aryStrStudentItemDesc[i]);
if (it != rBiMapStudentItemDescBefore.right.end())
{
    CString strNewStudentItemDesc = rBiMapStudentItemDescAfter.left.find(it->second)->second;
    pEntry->SetStudentAssignmentType(static_cast<StudentAssign>(i), strNewStudentItemDesc);

}