zoukankan      html  css  js  c++  java
  • boost tribool

    boost::logic::tribool is similar to bool. However, while bool can distinguish two states, boost::logic::tribool handles three.

    #include <boost/logic/tribool.hpp>
    #include <boost/logic/tribool_io.hpp>
    #include <iostream>
    
    using namespace boost::logic;
    
    int main() {
      std::cout.setf(std::ios::boolalpha);
    
      tribool b1 = true;
      std::cout << (b1 || indeterminate) << std::endl;
      std::cout << (b1 && indeterminate) << std::endl;
    
      tribool b2 = false;
      std::cout << (b2 || indeterminate) << std::endl;
      std::cout << (b2 && indeterminate) << std::endl;
    
      tribool b3 = indeterminate;
      std::cout << (b3 || b3) << std::endl;
      std::cout << (b3 && b3) << std::endl;
    
      return 0;
    }

    输出为:

    true

    indeterminate

    indeterminate

    false

    indeterminate

    indeterminate

    You can use logical operators with variables of type boost::logic::tribool, just as you can with variables of type bool. In fact, this is only way to process variables of type boost::logic::tribool because the class dosen't provide any member functions.

  • 相关阅读:
    mysql免安装使用(win7 64位系统)
    [NOIP2011]瑞士轮
    [NOIP2011]数的划分
    [洛谷2994]超级弹珠
    并查集
    [codevs1073]家族
    快速幂
    [NOI2002]银河英雄传说
    [NOIP2007]矩阵取数游戏
    [洛谷2415]集合求和
  • 原文地址:https://www.cnblogs.com/sssblog/p/11122721.html
Copyright © 2011-2022 走看看