代码之家  ›  专栏  ›  技术社区  ›  Roddy

tribool:奇怪的行为,还是错误?

  •  6
  • Roddy  · 技术社区  · 14 年前

    我在探索 boost::tribool 并对以下行为感到惊讶。

    {
    using namespace boost;
    
    boost::tribool t(indeterminate);
    
    assert(t==indeterminate);  // This assertion fails!
    } 
    

    但是,如果我这样做,断言就会通过。

    assert(indeterminate(t));
    

    两种情况下都没有编译器警告或错误。有人能很好地解释为什么会这样吗??

    1 回复  |  直到 14 年前
        1
  •  11
  •   UncleBens    14 年前

    我想答案在 documentation :

    这个 indeterminate