这是我的测试提振的样本:: tribool:升压tribool使用
#include <iostream>
#include "boost/logic/tribool.hpp"
int main()
{
boost::logic::tribool init;
//init = boost::logic::indeterminate;
init = true;
//init = false;
if (boost::logic::indeterminate(init))
{
std::cout << "indeterminate -> " << std::boolalpha << init << std::endl;
}
else if (init)
{
std::cout << "true -> " << std::boolalpha << init << std::endl;
}
else if (!init)
{
std::cout << "false -> " << std::boolalpha << init << std::endl;
}
bool safe = init.safe_bool(); <<---- error here
if (safe) std::cout << std::boolalpha << safe << std::endl;
return 0;
}
我想使用safe_bool()函数的boost :: tribool转换为纯布尔,但有请编译时错误:
Error 1 error C2274 : 'function-style cast' : illegal as right side of '.' operator D : \install\libs\boost\boost_samples\modules\tribool\src\main.cpp 23 1 tribool
看起来我错误地使用了safe_bool()函数。 你能帮我解决这个问题吗?谢谢。