boost tribool example

来源:互联网 发布:东风技术中心面试知乎 编辑:程序博客网 时间:2024/06/07 04:43

/*
 * =====================================================================================
 *
 *       Filename:  tribool.cpp
 *
 *    Description:  test boost tribool
 *
 *        Version:  1.0
 *        Created:  10/01/2009 07:33:17 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  rare
 *        Company: 
 *
 * =====================================================================================
 */

#include <iostream>
#include <boost/logic/tribool.hpp>
#include <boost/foreach.hpp>

void print(boost::tribool b)
{
    if (b)
    {
        std::cout<< "b is true" << std::endl;
    }
    else if (!b)
    {
        std::cout << "b is false" << std::endl;
    }
    else
    {
        std::cout << "b is indeterminate" << std::endl;
    }
}

int main()
{
    boost::tribool tbs[3] = {true, false, boost::indeterminate};

    BOOST_FOREACH(boost::tribool b, tbs)
    {
        print(b);   
    }
}

 

//output

b is true
b is false
b is indeterminate

原创粉丝点击