本文整理汇总了C++中Operator函数的典型用法代码示例。如果您正苦于以下问题:C++ Operator函数的具体用法?C++ Operator怎么用?C++ Operator使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Operator函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: if
void UnaryOpExpressionAST::typeCheck(TypeChecker& checker) {
mOperand->typeCheck(checker);
auto opType = mOperand->expressionType(checker);
if (mOp == Operator('!') && opType != checker.findType("Bool")) {
checker.typeError("The '!' operator can only be applied to values/variables of type 'Bool'.");
} else if (mOp == Operator('-') && opType != checker.findType("Int") && opType != checker.findType("Float")) {
checker.typeError("The '-' operator can only be applied to values/variables of type 'Int' or 'Float'.");
}
}
开发者ID:svenslaggare,项目名称:StackLang,代码行数:11,代码来源:operatorast.cpp
示例2: OP3
EXPR *ExprFindCommensurate( EXPR *expr )
{
unsigned int i, j ;
EXPR *tmp, *tmp2 ;
for( i = 0 ; i < U(UnitList)->used ; i++ )
{
if( U(UN(i))->used != U(expr)->used )
continue ;
for( j = 1 ; j < U(expr)->used ; j++ )
{
if( !BooleanValue( (BOOL*) OP3( "?=", U(UN(i))->list[j], U(expr)->list[j] ) ) )
break ;
}
if( j == U(expr)->used ) /* found one */
{
tmp = OP3( "/", U(expr)->list[0], U(UN(i))->list[0] ) ;
tmp2 = Real( MAGNITUDE( tmp ), i ) ;
delete tmp ;
delete expr ;
return tmp2 ;
}
}
for( i = 1 ; i < U(expr)->used ; i++ )
{
if( IS_ZERO( U(expr)->list[i] ) )
continue ;
if( MAGNITUDE( U(expr)->list[i] ) == 1.0 )
tmp = U(UN(i))->Ehead->Copy() ;
else
{
tmp = Operator( OPER_POW ) ;
D(tmp)->Eleft = U(UN(i))->Ehead->Copy() ;
D(tmp)->Eright = U(expr)->list[i]->Copy() ;
}
if( U(expr)->Eeval )
{
tmp2 = Operator( OPER_MULTIPLY ) ;
D(tmp2)->Eleft = U(expr)->Eeval ;
D(tmp2)->Eright = tmp ;
U(expr)->Eeval = tmp2 ;
}
else
U(expr)->Eeval = tmp ;
}
tmp = Real( MAGNITUDE( U(expr)->list[0] ), U(UnitList)->used ) ;
delete U(expr)->list[0] ;
U(expr)->list[0] = Real(1,0) ;
ListAppend( UnitList, expr ) ;
return tmp ;
}
开发者ID:skewray,项目名称:skewray_old,代码行数:53,代码来源:units.c
示例3: buildTwo
std::pair<MPI_Request, const K*>* buildTwo(Prcndtnr* B, const MPI_Comm& comm) {
static_assert(std::is_same<typename Prcndtnr::super&, decltype(*this)>::value || std::is_same<typename Prcndtnr::super::super&, decltype(*this)>::value, "Wrong preconditioner");
std::pair<MPI_Request, const K*>* ret = nullptr;
constexpr unsigned short N = std::is_same<typename Prcndtnr::super&, decltype(*this)>::value ? 2 : 3;
unsigned short allUniform[N + 1];
allUniform[0] = Subdomain<K>::_map.size();
const Option& opt = *Option::get();
unsigned short nu = allUniform[1] = (_co ? _co->getLocal() : static_cast<unsigned short>(opt["geneo_nu"]));
allUniform[2] = static_cast<unsigned short>(~nu);
if(N == 3)
allUniform[3] = nu > 0 ? nu : std::numeric_limits<unsigned short>::max();
{
MPI_Op op;
#ifdef __MINGW32__
MPI_Op_create(&f<N>, 1, &op);
#else
auto f = [](void* in, void* inout, int*, MPI_Datatype*) -> void {
HPDDM_LAMBDA_F(in, input, inout, output, N)
};
MPI_Op_create(f, 1, &op);
#endif
MPI_Allreduce(MPI_IN_PLACE, allUniform, N + 1, MPI_UNSIGNED_SHORT, op, comm);
MPI_Op_free(&op);
}
if(nu > 0 || allUniform[1] != 0 || allUniform[2] != std::numeric_limits<unsigned short>::max()) {
if(!_co) {
_co = new CoarseOperator;
_co->setLocal(nu);
}
double construction = MPI_Wtime();
if(allUniform[1] == nu && allUniform[2] == static_cast<unsigned short>(~nu))
ret = _co->template construction<1, excluded>(Operator(*B, allUniform[0]), comm);
else if(N == 3 && allUniform[1] == 0 && allUniform[2] == static_cast<unsigned short>(~allUniform[3]))
ret = _co->template construction<2, excluded>(Operator(*B, allUniform[0]), comm);
else
ret = _co->template construction<0, excluded>(Operator(*B, allUniform[0]), comm);
construction = MPI_Wtime() - construction;
if(_co->getRank() == 0 && opt.val<int>("verbosity") > 0) {
std::stringstream ss;
ss << std::setprecision(2) << construction;
std::string line = " --- coarse operator transferred and factorized by " + to_string(static_cast<int>(opt["master_p"])) + " process" + (static_cast<int>(opt["master_p"]) == 1 ? "" : "es") + " (in " + ss.str() + "s)";
std::cout << line << std::endl;
std::cout << std::right << std::setw(line.size()) << "(criterion = " + to_string(allUniform[1] == nu && allUniform[2] == static_cast<unsigned short>(~nu) ? nu : (N == 3 && allUniform[2] == static_cast<unsigned short>(~allUniform[3]) ? -_co->getLocal() : 0)) + " -- topology = " + to_string(static_cast<int>(opt["master_topology"])) + " -- distribution = " + to_string(static_cast<int>(opt["master_distribution"])) + ")" << std::endl;
std::cout.unsetf(std::ios_base::adjustfield);
}
}
else {
delete _co;
_co = nullptr;
}
return ret;
}
开发者ID:feelpp,项目名称:hpddm,代码行数:52,代码来源:preconditioner.hpp
示例4: main
main() {
int k, n, a, b;
for(a = 0; a < 10002; a++) LOW[a] = a & (-a);
scanf("%d", &k);
while(k--) {
scanf("%d", &n);
for(a = 0; a < n; a++)
scanf("%d %d %d", &A[a].a, &A[a].b, &A[a].c),
B[a].a = A[a].b, B[a].b = A[a].a, B[a].c = A[a].c;
MergeSort(0, n-1, A), MergeSort(0, n-1, B);
int Pa, Pb, Pc, t, Ans = 0;
for(a = 0; a < n; ) {
Pa = A[a].a;
while(a < n && A[a].a <= Pa) a++;
memset(C, 0, (10000-Pa+2)*4);
for(b = 0; b < n && Pa+B[b].a <= 10000; ) {
Pb = B[b].a, Pc = 10000-Pa-Pb+1;
while(b < n && B[b].a <= Pb) {
if(B[b].b <= Pa) Modify(B[b].c+1, Pc);
b++;
}
t = Operator(Pc);
Ans = Ans > t ? Ans : t;
}
}
printf("%d\n", Ans);
}
return 0;
}
开发者ID:JohnXinhua,项目名称:UVa,代码行数:29,代码来源:b212.+E.+不景氣的年代.cpp
示例5: Autonomous599
//599 funcitons
void Autonomous599()
{
while(true)
{
if((SensorValue[kill_sw] < 127)&& ENABLE_KILL_SWITCH) //kill button on robot is A/D port to save digital ports
{
if(script != no_script) // stop scripts by reinitializing
{
Initialize();
bsingle_step_mode = false;
}
allMotorsOff();
break;
}
Process_sensors(); // read and process sensors to get variables needed for functions
Operator(); // read driver commands from joystick which are not under script control
Select_autonomous_script();//call autonomous script based upon cortex input auto_select (in8) port status
Run_scripts();// Runs the selected script from Select_autonomous_script() to get commnads from scripts
//call core functions here that use commands from operator() and run_scripts() functions
Core_functions();
}//end while
}
开发者ID:ArtskydJ,项目名称:robotc-source,代码行数:34,代码来源:599_Competition_Scripting_Template.c
示例6: work
void work(void)
{
//number of elements to work with
auto elems = this->workInfo().minElements;
if (elems == 0) return;
//access to input ports and output port
const std::vector<Pothos::InputPort *> &inputs = this->inputs();
Pothos::OutputPort *output = this->output(0);
//establish pointers to buffers
auto out = Pothos::BufferChunk(output->buffer()).as<Type *>();
auto in0 = inputs[0]->buffer().as<const Type *>();
if (out == in0) _numInlineBuffers++; //track buffer inlining
//loop through available ports
for (size_t i = 1; i < inputs.size(); i++)
{
auto *inX = inputs[i]->buffer().as<const Type *>();
Operator(in0, inX, out, elems*output->dtype().dimension());
in0 = out; //operate on output array next loop
inputs[i]->consume(elems); //consume on ith input port
}
//produce and consume on 0th ports
inputs[0]->consume(elems);
output->produce(elems);
}
开发者ID:pothosware,项目名称:pothos-comms,代码行数:28,代码来源:Arithmetic.cpp
示例7: gen_text
AttributePtr gen_text(const RuleTable& print_rules, NodePtr root,
BindingsPtr bindings) {
const Rules& rules(bindings->get_rules());
std::ostringstream os;
if (rules.operator_rules_defined()) {
NodePtr cloned_root = clone_including_attributes(root);
/*
the parentheses operator can be configured through
the operator set named "parentheses";
Op::LPAREN is taken by default
*/
OperatorSetPtr parenthesesSet = rules.get_opset("parentheses");
Operator parentheses;
if (parenthesesSet && parenthesesSet->get_card() == 1) {
OperatorSet::Iterator it = parenthesesSet->begin();
parentheses = Operator(*it);
} else {
parentheses = Op::LPAREN;
}
parenthesize(cloned_root, rules.get_operator_table(), parentheses);
root = cloned_root;
}
if (print(os, root, print_rules, bindings)) {
return std::make_shared<Attribute>(os.str());
} else {
return AttributePtr(nullptr);
}
}
开发者ID:afborchert,项目名称:astl,代码行数:28,代码来源:printer.cpp
示例8: GroupStart
void GroupStart() override
{
FlushOperations();
Ops.push(Operator(GROUP_START));
Delegate.GroupStart();
LastIsMatch = false;
}
开发者ID:djdron,项目名称:zxtune,代码行数:7,代码来源:syntax.cpp
示例9: Operation
void Operation(const std::string& op) override
{
const std::size_t usedVals = Operator(op).Parameters();
CheckAvailableParameters(usedVals, Position);
Position = Position - usedVals + 1;
Delegate.Operation(op);
}
开发者ID:djdron,项目名称:zxtune,代码行数:7,代码来源:syntax.cpp
示例10: move
//===--------------------------------------------------------------------===//
// PhysicalSortGroupBy
//===--------------------------------------------------------------------===//
Operator PhysicalSortGroupBy::make(
std::vector<std::shared_ptr<expression::AbstractExpression>> columns,
std::vector<AnnotatedExpression> having) {
PhysicalSortGroupBy *agg = new PhysicalSortGroupBy;
agg->columns = std::move(columns);
agg->having = move(having);
return Operator(agg);
}
开发者ID:saifalharthi,项目名称:peloton,代码行数:11,代码来源:operators.cpp
示例11: Operator
//===--------------------------------------------------------------------===//
// Get
//===--------------------------------------------------------------------===//
Operator LogicalGet::make(storage::DataTable *table,
std::vector<Column *> cols)
{
LogicalGet *get = new LogicalGet;
get->table = table;
get->columns = cols;
return Operator(get);
}
开发者ID:abpoms,项目名称:peloton-opt,代码行数:11,代码来源:operators.cpp
示例12: compile
Type
compile(const Node& l, const UnaryOperator& op, Context& ctx)
{
auto l_type = l.compile(ctx);
if(op == Operator('&'))
{
if(l_type != TypeKind::reference)
{
printf("参照でないオブジェクトのアドレスを取得しようとしました\n");
throw;
}
return I32Type();
}
if(l_type == TypeKind::reference)
{
l_type = l_type.compile_dereference(ctx);
}
switch(op)
{
case(Operator('*')):
if(l_type != TypeKind::pointer)
{
printf("ポインタでないオブジェクトを参照しようとしました\n");
throw;
}
return l_type.make_reference();
break;
case(Operator('!')): ctx.push(" lnot;\n");break;
case(Operator('~')): ctx.push(" bnot;\n");break;
case(Operator('-')): ctx.push(" neg ;\n");break;
}
return I32Type();
}
开发者ID:mugisaku,项目名称:libmkf,代码行数:46,代码来源:expression_operator.cpp
示例13: bool
void Operator::Register(uint16_t opcode, bool (*o)(const Context &, uint16_t &index))
{
if (Operators[opcode]._operator) {
Operators[opcode].setOverload(o);
} else {
Operators[opcode] = Operator(o);
}
}
开发者ID:sandsmark,项目名称:replicode,代码行数:8,代码来源:operator.cpp
示例14: Operator
//===--------------------------------------------------------------------===//
// PhysicalUpdate
//===--------------------------------------------------------------------===//
Operator PhysicalUpdate::make(
std::shared_ptr<catalog::TableCatalogObject> target_table,
const std::vector<std::unique_ptr<peloton::parser::UpdateClause>> *
updates) {
PhysicalUpdate *update = new PhysicalUpdate;
update->target_table = target_table;
update->updates = updates;
return Operator(update);
}
开发者ID:saifalharthi,项目名称:peloton,代码行数:12,代码来源:operators.cpp
示例15: PostOrder
void PostOrder(BTree *tree)
{
if(tree==NULL)
return;
if(tree->lchild!=NULL)
PostOrder(tree->lchild);
if(tree->rchild!=NULL)
PostOrder(tree->rchild);
Operator(tree->data);
}
开发者ID:Lonui-NC,项目名称:Algorithm,代码行数:10,代码来源:OrderTree.c
示例16: PhysicalInnerHashJoin
//===--------------------------------------------------------------------===//
// InnerHashJoin
//===--------------------------------------------------------------------===//
Operator PhysicalInnerHashJoin::make(
std::vector<AnnotatedExpression> conditions,
std::vector<std::unique_ptr<expression::AbstractExpression>>& left_keys,
std::vector<std::unique_ptr<expression::AbstractExpression>>& right_keys) {
PhysicalInnerHashJoin *join = new PhysicalInnerHashJoin();
join->join_predicates = std::move(conditions);
join->left_keys = std::move(left_keys);
join->right_keys = std::move(right_keys);
return Operator(join);
}
开发者ID:saifalharthi,项目名称:peloton,代码行数:13,代码来源:operators.cpp
示例17: Operator
/**
* Constructor for a leaf (number) node
*/
Expression::Expression(Number num)
{
// Initilize the pointers to null
this->left = nullptr;
this->right = nullptr;
// Initilize the operation to the null operatoon
this->op = Operator();
// Initlize the number to num
this->num = num;
}
开发者ID:UF-COP-3053-Group,项目名称:COP-3503-Project,代码行数:15,代码来源:Expression.cpp
示例18: Tokenize
//This function responds to the user commands
void Scheduler::Invoke(String binaryInput)
{
Tokenize(binaryInput);
if(elevatorID==3) //special code for toggling userType (shortage of input pins)
return;
if(userType == "Operator")
{Operator();return;}
else
{Passenger();return;}
}
开发者ID:programenthusiast813,项目名称:elevator_control_system,代码行数:13,代码来源:Scheduler.cpp
示例19:
std::shared_ptr<Type> BinaryOpExpressionAST::expressionType(const TypeChecker& checker) const {
auto& boolTypes = checker.operators().binaryOpReturnTypes();
if (boolTypes.count(mOp) > 0) {
return boolTypes.at(mOp);
} else {
if (mOp == Operator('=')) {
return checker.findType("Void");
} else {
return mLeftHandSide->expressionType(checker);
}
}
}
开发者ID:svenslaggare,项目名称:StackLang,代码行数:13,代码来源:operatorast.cpp
示例20: Operator
BOOL CCalculator::Expression(CCalcExpression** ppcExpression)
{
BOOL bOperator;
BOOL bOperand;
BOOL bFirst;
CArrayIntAndPointer cArray;
CCalcOperator* pcOperator;
CCalcExpression* pcOperand;
cArray.Init(16);
bFirst = TRUE;
for (;;)
{
for (;;)
{
bOperator = Operator(&pcOperator);
if (!bOperator)
{
break;
}
cArray.Add(pcOperator, 0);
}
bOperand = Operand(&pcOperand);
if (!bOperand && !bOperator)
{
if (bFirst)
{
cArray.Kill();
return FALSE;
}
else
{
BuildExpression(ppcExpression, &cArray);
cArray.Kill();
if (*ppcExpression == NULL)
{
return FALSE;
}
else
{
return TRUE;
}
}
}
cArray.Add(pcOperand, 0);
bFirst = FALSE;
}
}
开发者ID:chrisjaquet,项目名称:Codaphela.Library,代码行数:51,代码来源:Calculator.cpp
注:本文中的Operator函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论