本文整理汇总了C++中Val类的典型用法代码示例。如果您正苦于以下问题:C++ Val类的具体用法?C++ Val怎么用?C++ Val使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Val类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: test_capture_var
void test_capture_var() {
template_capture_var<int>(); // OK
template_capture_var<int&>(); // expected-note{{in instantiation of function template specialization 'template_capture_var<int &>' requested here}}
Val<float> Obj;
Obj.set(0.0f); // OK
}
开发者ID:AlexDenisov,项目名称:clang,代码行数:7,代码来源:captured-statements.cpp
示例2: upheap
bool
ValHeap::
upheap(int pos)
{
if(print) cerr << "in Upheap " << pos << " " << array.size() << endl;
if(pos == 0) return false;
Val* atp = array[pos];
assert(atp);
double merit = atp->fom();
int parPos = parent(pos);
Val* par = array[parPos];
double pmerit = par->fom();
if(print) cerr << "merits " << merit << " " << pmerit<< endl;
if(merit > pmerit)
{
array[parPos] = atp;
array[pos] = par;
if(print) cerr << "Put " << pos << " in " << parPos << endl;
upheap(parPos);
return true;
}
else if(print)
{
cerr << "upheap of " << merit << "stopped by "
<< parPos << " " << pmerit << endl;
}
return false;
}
开发者ID:chrisleewashere,项目名称:SwiRL-OSX,代码行数:28,代码来源:ValHeap.C
示例3: apply
Val*
ClassRule::
apply(FullHist* treeh)
{
Val* trdTree = NULL;
Bchart* cb = treeh->cb;
assert(cb);
Val* curVal = cb->curVal;
Val* gcurVal = cb->gcurVal;
int curDir = cb->curDir;
//int wI = Feature::whichInt;
//wcerr << "AP " << *this << endl;
//if(curVal) wcerr << "APCV " << *curVal << endl;
if(rel_ == 0)
{
trdTree = gcurVal;
}
else if(rel_ == 1) trdTree = sibling_tree(curVal, curDir);
else if(rel_ == 2) trdTree = rel2_tree(curVal, curDir);
else if(rel_ == 4) trdTree = curVal;
else error(L"bad relation");
if(!trdTree)
{
return NULL;
}
int ct = trdTree->trm();
//wcerr << "foudn " << t_ << " " << ct << " " << *trdTree << endl;
if(t_ != ct)
{
return NULL;
}
return trdTree;
}
开发者ID:dorony,项目名称:CharniakParserWindows,代码行数:33,代码来源:ClassRule.cpp
示例4: eval
int Assignement::execute(Env* e, Store* s) {
Val v = eval(s,e);
if(v.getType() == EMPTY) {
return 1;
}
return 0;
}
开发者ID:tfrancoi,项目名称:Happy-V2,代码行数:8,代码来源:instr.cpp
示例5:
bool
operator==(Val& v1, Val& v2)
{
if(v1.edge() != v2.edge()) return false;
shortIter si2 = v2.vec().begin();
for(shortIter si = v1.vec().begin(); si != v1.vec().end() ; si++)
{
if((*si) != (*si2)) return false;
si2++;
}
return true;
}
开发者ID:chrisleewashere,项目名称:SwiRL-OSX,代码行数:12,代码来源:Bst.C
示例6: tree_ruleHead_third
int
tree_ruleHead_third(FullHist* treeh)
{
Val* specTree = NULL;
if(Feature::isLM) specTree = tree_ruleTree(treeh, 2);
if(specTree)
{
FullHist* pt = treeh->back;
if(!pt) return nullWordInt;
int ans = pt->hd->toInt();
return ans;
}
Val* trdtree = tree_ruleTree(treeh,3);
if(!trdtree) return nullWordInt;
else return trdtree->wrd();
}
开发者ID:KerstenDoering,项目名称:CPI-Pipeline,代码行数:16,代码来源:fhSubFns.C
示例7: fh_parent_head
int
fh_parent_head(FullHist* tree)
{
Val* spectree = NULL;
if(Feature::isLM) spectree = tree_ruleTree(tree, 2);
if(spectree)
{
//cerr << "found st " << endl;
return spectree->wrd();
}
FullHist* pt = tree->back;
if(!pt) return nullWordInt;
int ans = pt->hd->toInt();
assert(ans >= -1);
return ans;
}
开发者ID:KerstenDoering,项目名称:CPI-Pipeline,代码行数:16,代码来源:fhSubFns.C
示例8: toVal
template<typename T> inline static void toVal(Val& mV, T&& mX)
{
Arr result; result.reserve(sizeof...(TArgs));
// TODO: fwd macro?
tplFor([&result](auto&& mI){ result.emplace_back(fwd<decltype(mI)>(mI)); }, fwd<T>(mX));
mV.setArr(std::move(result));
}
开发者ID:questor,项目名称:git-ws,代码行数:7,代码来源:Cnv.hpp
示例9: weight
void AvgAggrLitPrinter::weight(const Val &v)
{
int num = v.number();
min_ = std::min(min_, num);
max_ = std::max(max_, num);
output_->addToList(symbol_, v);
}
开发者ID:RayHuo,项目名称:iASP,代码行数:7,代码来源:reifiedoutput_impl.cpp
示例10: SSVU_ATTRIBUTE
inline static bool SSVU_ATTRIBUTE(pure) areArrItemsOfType(const Val& mV) noexcept
{
SSVU_ASSERT(mV.is<Arr>());
for(const auto& v : mV.getArr())
if(!v.template isNoNum<T>()) return false;
return true;
}
开发者ID:SuperV1234,项目名称:SSVUtils,代码行数:7,代码来源:Chk.hpp
示例11: toVal
template<typename T> inline static void toVal(Val& mV, T&& mX)
{
mV.setArr(Arr
{
Val{moveIfRValue<decltype(mX)>(mX.first)},
Val{moveIfRValue<decltype(mX)>(mX.second)}
});
}
开发者ID:sonyomega,项目名称:SSVUtils,代码行数:8,代码来源:Cnv.hpp
示例12: isTpl
inline static EnableIf <
TI<sizeof...(TArgs), bool> isTpl(const Val& mV) noexcept
{
SSVU_ASSERT(mV.is<Arr>() && mV.getArr().size() > TI);
if(!mV[TI].isNoNum<TplArg<TI, Tpl<TArgs...>>>())
return false;
return isTpl<TI + 1, TArgs...>(mV);
}
开发者ID:SuperV1234,项目名称:SSVUtils,代码行数:8,代码来源:Chk.hpp
示例13: switch
Val *Parser::parseLitVal(){
Val *v;
Type *ty;
switch( curr() ){
case T_INTCONST:
v=new Val( toint(text()) );
ty=Type::int32;
break;
case T_FLOATCONST:
v=new Val( tofloat(text()) );
ty=Type::float32;
break;
default:
exp( "integer or floating point literal value" );
}
next();
ty=parseLitType( ty );
return v->cast( ty );
}
开发者ID:STLVNUB,项目名称:blitzmax,代码行数:19,代码来源:parser.cpp
示例14: throw
tribool ParityAggrLit::accumulate(Grounder *g, const Val &weight, Lit &lit) throw(const Val*)
{
(void)g;
int32_t num = weight.number();
if(num % 2 == 0 && !head()) return true;
if(set_ && !lit.testUnique(uniques_)) return true;
if(!lit.fact()) factOnly_ = false;
else if (num % 2 != 0) fixed_ = !fixed_;
return lit.fact() ? tribool(true) : unknown;
}
开发者ID:RayHuo,项目名称:iASP,代码行数:10,代码来源:parityaggrlit.cpp
示例15: Env
Val Call::eval(Store* s, Env* e) {
function::Function *f = NULL;
NFunction *nf = NULL;
Val v = e->get(this->name);
if(VERBOSE)
cout << "call => " << name << endl;
if(v.getType() == FUNCTION) {
if(v.to_function()->getType() == NATIVE_FUNCTION) {
nf = dynamic_cast<NFunction*>(v.to_function());
}
else {
f = dynamic_cast<function::Function*>(v.to_function());
}
}
else {
f = ::getProgFunction(name);
nf = ::getNativeFunction(name);
}
if(f != NULL) {
Env *ne = new Env(f->getNbVar());
if(argument.size() != f->getArity()) {
cout << "wrong arity during calling " << name << ", expected " << f->getArity() << ", " << argument.size() << " given " << endl;
exit(1);
}
for(unsigned int i = 0; i < argument.size(); i++) {
ne->set(i, argument[i]->eval(s,e), f->getVarName(i));
}
f->execute(ne, s);
Val v = ne->get(f->getNbVar());
delete ne;
return v;
}
if(nf != NULL) {
return nf->eval(s,e,argument, this->line(), this->file());
}
cout << "undefined symbol " << name << endl;
return Val();
}
开发者ID:tfrancoi,项目名称:Happy-V2,代码行数:42,代码来源:instr.cpp
示例16: invertImage
vector<char> LodepngDecodePolicy::Encode(uImage img, bool flip)
{
Val data = flip ? invertImage(move(img.data), img.height, img.width * img.channels) : move(img.data);
LodePNGColorType colortype = LCT_RGB;
switch(img.channels)
{
case 1: colortype = LCT_GREY; break;
case 3: colortype = LCT_RGB; break;
case 4: colortype = LCT_RGBA; break;
default: CASSERT(0, "Invalid channels for image saving");
}
ubyte* buff = nullptr;
size_t buff_s = 0;
if(Val error = lodepng_encode_memory(&buff, &buff_s, data.data(), img.width, img.height, colortype, 8))
CERROR("Lodepng error: "<<lodepng_error_text(error));
vector<char> image(buff, buff + buff_s);
free(buff);
return image;
}
开发者ID:installgentoo,项目名称:opengl_gui,代码行数:21,代码来源:resource.cpp
示例17: Val
Val Id::eval(Store* s, Env* e) {
Val v = e->get(ref);
if(v.to_s() == "(-> Empty <-)") {
function::Function *f = ::getProgFunction(name);
NFunction *nf = ::getNativeFunction(name);
if(f == NULL) {
if(nf == NULL) {
cout << "variable " << name << " not define " << endl;
}
else {
return Val(nf);
}
}
else {
//cout << "on a trouvé la fonction" << endl;
return Val(f);
}
}
return v;
}
开发者ID:tfrancoi,项目名称:Happy-V2,代码行数:21,代码来源:expr.cpp
示例18: newIth
Val*
Val::
newIth(int ith, Val* oval, bool& stop)
{
int ithc = oval->vec(ith);
if(ithc > 0) stop = true;
short nxtI = ithc +1;;
//cerr<< "Wnt " << nxtI << "th var on pos " << ith << " of " << *oval<< endl;
if(oval->wrd() >= 0) return NULL; //???;
double ovalprob = oval->prob();
//if(oval->status == TERMINALVAL) return NULL;
Val* nval = ithBst(ith,oval->bsts()).next(nxtI);
if(!nval) return NULL;
double ovalcompprob = ithBst(ith, oval->bsts()).nth(ithc)->prob();
double nprob = nval->prob();
//cerr << "Its prob is " << nprob << endl;
if(nprob < 0) return NULL;
Val* ans = new Val(oval);
ans->vec(ith) = nxtI;
double frac = nprob/ovalcompprob;
ans->prob() *= frac;
assert(nxtI <= ithBst(ith,ans->bsts()).num());
//cerr << "ith is " << ith << " " << ans->vec().size() << " "
// << ans->vec()[ith] << " " << frac << endl;
//cerr << "The var is " << *ans << endl;
//assert(ans->check());
return ans;
}
开发者ID:chrisleewashere,项目名称:SwiRL-OSX,代码行数:28,代码来源:Bst.C
示例19: if
CGExp *Parser::parseLitExp( Type *ty ){
int sign=0;
for(;;){
if( cparse('+') ){
}else if( cparse('-') ){
sign=sign ? -sign : -1;
}else{
break;
}
}
Val *v;
switch( curr() ){
case T_INTCONST:{
int64 n=toint(text());
if( sign<0 ) n=-n;
v=new Val( n );
next();
break;
}
case T_FLOATCONST:{
double n=tofloat(text());
if( sign<0 ) n=-n;
v=new Val( n );
next();
break;
}
case T_STRINGCONST:{
if( sign ) exp( "Numeric or string literal value" );
v=new Val( parseBString() );
break;
}
default:
exp( "Numeric or string literal value" );
}
ty=parseLitType( ty );
v=v->cast( ty );
return v->cg_exp;
}
开发者ID:STLVNUB,项目名称:blitzmax,代码行数:38,代码来源:parser.cpp
示例20: downHeap
void
ValHeap::
downHeap(int pos)
{
if(print) cerr << "downHeap " << pos << endl;
if(pos >= unusedPos_-1) return;
Val* par = array[pos];
double merit = par->fom();
int lc = left_child(pos);
int rc = right_child(pos);
int largec;
int lcthere = 0;
Val* lct = NULL;
if(lc < unusedPos_)
{
lct = array[lc];
if(lct) lcthere = 1;
}
int rcthere = 0;
Val* rct = NULL;
if(rc < unusedPos_)
{
rct = array[rc];
if(rct) rcthere = 1;
}
if(!lcthere && !rcthere) return;
assert(lcthere);
if(!rcthere || (lct->fom() > rct->fom()))
largec = lc;
else largec = rc;
Val* largeatp = array[largec];
if(merit >= largeatp->fom())
{
if(print) cerr << "downheap of " << merit << " stopped by "
<< " " << largeatp->fom() << endl;
return;
}
array[pos] = largeatp;
array[largec] = par;
downHeap(largec);
}
开发者ID:chrisleewashere,项目名称:SwiRL-OSX,代码行数:41,代码来源:ValHeap.C
注:本文中的Val类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论