本文整理汇总了C++中Predicate::isTrue方法的典型用法代码示例。如果您正苦于以下问题:C++ Predicate::isTrue方法的具体用法?C++ Predicate::isTrue怎么用?C++ Predicate::isTrue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Predicate
的用法示例。
在下文中一共展示了Predicate::isTrue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Or
Predicate Predicate::Or(Predicate left, Predicate right) {
if (left.isTrue() || right.isTrue()) {
return Predicate::True();
} else if (left.isFalse()) {
return right;
} else if (right.isFalse()) {
return left;
} else if (left == right) {
return left;
} else if (left.isOr() && (left.orLeft() == right || left.orRight() == right)) {
return left;
} else if (right.isOr() && (right.orLeft() == left || right.orRight() == left)) {
return right;
}
Predicate predicate(OR);
predicate.left_ = std::unique_ptr<Predicate>(new Predicate(std::move(left)));
predicate.right_ = std::unique_ptr<Predicate>(new Predicate(std::move(right)));
return predicate;
}
示例2: And
Predicate Predicate::And(Predicate left, Predicate right) {
if (left.isFalse() || right.isFalse()) {
return Predicate::False();
} else if (left.isTrue()) {
return right;
} else if (right.isTrue()) {
return left;
} else if (left == right) {
return left;
} else if (left.isAnd() && (left.andLeft() == right || left.andRight() == right)) {
return left;
} else if (right.isAnd() && (right.andLeft() == left || right.andRight() == left)) {
return right;
}
Predicate predicate(AND);
predicate.left_ = std::unique_ptr<Predicate>(new Predicate(std::move(left)));
predicate.right_ = std::unique_ptr<Predicate>(new Predicate(std::move(right)));
return predicate;
}
示例3: PredicateExpr
Value Value::PredicateExpr(Predicate predicate, const Type* const boolType) {
if (predicate.isTrue()) {
return Value::Constant(Constant::True(), boolType);
} else if (predicate.isFalse()) {
return Value::Constant(Constant::False(), boolType);
} else if (predicate.isVariable()) {
return Value::TemplateVarRef(predicate.variableTemplateVar(), boolType);
}
Value value(PREDICATE, boolType, ExitStates::Normal());
value.impl_->predicate = make_optional(std::move(predicate));
return value;
}