int main() { Foo F; Foo *F2 = new Foo(); new Foo(); Foo(); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type 'Foo' is prohibited Foo F3 = Foo(); // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: creating a temporary object of type 'Foo' is prohibited Bar(); NS::Bar(); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type 'NS::Bar' is prohibited int A = func(Foo()); // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: creating a temporary object of type 'Foo' is prohibited Foo F4(0); Foo *F5 = new Foo(0); new Foo(0); Foo(0); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type 'Foo' is prohibited Foo F6 = Foo(0); // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: creating a temporary object of type 'Foo' is prohibited Bar(0); NS::Bar(0); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: creating a temporary object of type 'NS::Bar' is prohibited int B = func(Foo(0)); // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: creating a temporary object of type 'Foo' is prohibited }
void Data::parsePrices(QString page) { bool isPriceUpdated = false; // prices in the feed are from newest to oldest so we want the first Data::ctime = QDateTime::fromString(page.section("<latest_timestamp>",1,1).left(14), "yyyyMMddhhmmss"); if(cstyle%Constants::getStyle()->size() == 1) { dataBars = new QList<Bar>(); QStringListIterator listIterator(page.split("<bar>")); if(listIterator.hasNext()) { listIterator.next(); // skip the "0" index xmin = 999999; xmax = 0; ymin = 99999999; ymax = 0; } while(listIterator.hasNext()) { QString nextBar = listIterator.next(); QString lowStr = nextBar.section("<low>",1,1).section("</low>",0,0); QString highStr = nextBar.section("<high>",1,1).section("</high>",0,0); QString closeStr = nextBar.section("<close>",1,1).section("</close>",0,0); if(closeStr != "") { if(lowStr.toDouble() < ymin) ymin = lowStr.toDouble(); if(highStr.toDouble() > ymax) ymax = highStr.toDouble(); dataBars->prepend(Bar(lowStr.toDouble(), highStr.toDouble(), closeStr.toDouble())); } else { dataBars->prepend(Bar()); } if(!isPriceUpdated && closeStr.toDouble() > 0) { isPriceUpdated = true; lastChartPrice = closeStr.toDouble(); } } xmax = dataBars->size()+1.5; } else if(cstyle%Constants::getStyle()->size() == 0) { dataPoints = new QList<double>(); QStringListIterator listIterator(page.split("<point>")); if(listIterator.hasNext()) { listIterator.next(); // skip the "0" index xmin = 999999; xmax = 0; ymin = 999999; ymax = 0; } while(listIterator.hasNext()) { QString nextPoint = listIterator.next(); QString priceStr = nextPoint.section("<price>",1,1).section("</price>",0,0); if(priceStr != "") { if(priceStr.toDouble() < ymin) ymin = priceStr.toDouble(); if(priceStr.toDouble() > ymax) ymax = priceStr.toDouble(); dataPoints->prepend(priceStr.toDouble()); } else { dataPoints->prepend(-1); } if(!isPriceUpdated && priceStr.toDouble() > 0) { isPriceUpdated = true; lastChartPrice = priceStr.toDouble(); } } xmax = dataPoints->size()+1.5; } xmin = 0; double ydiff = ymax - ymin; ymin = ymin-ydiff/20; ymax = ymax+ydiff/20; // 'callback' to chart to update once the data is parsed chart->update(); }
int64_t decode(void *buffer, size_t size, int64_t sum) { unsigned int i; C(table_t) foobarcontainer; FooBar(vec_t) list; FooBar(table_t) foobar; Bar(struct_t) bar; Foo(struct_t) foo; foobarcontainer = C(as_root(buffer)); sum += C(initialized(foobarcontainer)); sum += StringLen(C(location(foobarcontainer))); sum += C(fruit(foobarcontainer)); list = C(list(foobarcontainer)); for (i = 0; i < FooBar(vec_len(list)); ++i) { foobar = FooBar(vec_at(list, i)); sum += StringLen(FooBar(name(foobar))); sum += FooBar(postfix(foobar)); sum += (int64_t)FooBar(rating(foobar)); bar = FooBar(sibling(foobar)); sum += (int64_t)Bar(ratio(bar)); sum += Bar(size(bar)); sum += Bar(time(bar)); foo = Bar(parent(bar)); sum += Foo(count(foo)); sum += Foo(id(foo)); sum += Foo(length(foo)); sum += Foo(prefix(foo)); } return sum + 2 * sum; }
int main() { My my; Bar(my); // OK My2 my2; Bar(my2); // Compile error: no type named ‘foo’ in ‘struct My2’ return 0; }
void bar() { std::cout << "========== Bar ==============\n"; Bar b = Bar() + Bar(); std::cout << "=============================\n"; }
void tst_QHash::dont_need_default_constructor() { QHash<int, Bar> hash1; for (int i = 0; i < 100; ++i) { hash1.insert(i, Bar(2 * i)); QVERIFY(hash1.value(i, Bar(-1)).j == 2 * i); QVERIFY(hash1.size() == i + 1); } QHash<QString, Bar> hash2; for (int i = 0; i < 100; ++i) { hash2.insert(QString::number(i), Bar(2 * i)); QVERIFY(hash2.value(QString::number(i), Bar(-1)).j == 2 * i); QVERIFY(hash2.size() == i + 1); } }
void LoadDatabase(QueryResult * pResult) { pResult = SD2Database.PQuery( "SELECT flag, data0, data1, CatId, C.name, destid " "FROM sd2p_npc_tele_category C, sd2p_npc_tele_association A " "WHERE C.id = CatId ORDER BY C.name, CatId"); VCategorie.clear(); if (pResult) { outstring_log("SD2P: Chargement \"sd2p_npc_tele_category\" et \"sd2p_npc_tele_association\"..."); barGoLink Bar(pResult->GetRowCount()); uint32 CatId = 0; uint32 NbDest = 0; bool IsValidCat = true; bool FirstTime = true; do { Bar.step(); Field * pFields = pResult->Fetch(); if (!GetDestination(pFields[5].GetUInt32())) { outstring_log("SD2P >> Destination introuvable (DestID: %u).", pFields[5].GetUInt32()); continue; } if (!IsValidCat && CatId == pFields[3].GetUInt32() && !FirstTime) continue; IsValidCat = true; FirstTime = false; if (!IsValidData(pFields[3].GetUInt32(), (Flag_t)pFields[0].GetUInt8(), pFields[1].GetUInt64(), pFields[2].GetUInt32())) { IsValidCat = false; CatId = pFields[3].GetUInt32(); continue; } if (CatId != pFields[3].GetUInt32()) { CatId = pFields[3].GetUInt32(); Categorie Cat (CatId, pFields[4].GetCppString(), (Flag_t)pFields[0].GetUInt8(), pFields[1].GetUInt64(), pFields[2].GetUInt32()); VCategorie.push_back(Cat); } VCategorie.back().AddDest(pFields[5].GetUInt32()); ++NbDest; } while (pResult->NextRow()); delete pResult; outstring_log(""); outstring_log(">> %u npc_teleport charge(s).", NbDest); } else outstring_log("WARNING >> 0 npc_teleport charge."); }
int main() { Bar bar = Bar(); bar.Bartender(); return 0; }
int main() { Bar Bar(1); class Bar Bar2(2); // elaborated type printf("hello"); }
int main() { union union_64 param1, param2; param1._uint8[0]=0xde; param1._uint8[1]=0xad; param1._uint8[2]=0xbe; param1._uint8[3]=0xef; param1._uint8[4]=0xde; param1._uint8[5]=0xad; param1._uint8[6]=0xbe; param1._uint8[7]=0xef; param2._uint8[0]=0xde; param2._uint8[1]=0xad; param2._uint8[2]=0xbe; param2._uint8[3]=0xef; param2._uint8[4]=0xde; param2._uint8[5]=0xad; param2._uint8[6]=0xbe; param2._uint8[7]=0x7f; Bar(param1.i64, param2.i64); return 0; }
/********************************************************************* * Function: WORD CcDraw(CUSTOM *pCc) * * PreCondition: object must be created before this is called * * Input: pCc - pointer to struct CUSTOM with data * * Output: returns the status of the drawing * 0 - not complete * 1 - done * * Overview: draws control * * Note: THIS FUNCTION CALL SHOULD BE ADDED INTO GOLDraw() FUNCTION IN * GOL.C FILE * ********************************************************************/ WORD CcDraw(CUSTOM *pCc) { typedef enum { REMOVE, BOX_DRAW, RUN_DRAW } CC_DRAW_STATES; static CC_DRAW_STATES state = REMOVE; switch(state) { case REMOVE: if(GetState(pCc, CC_HIDE)) { SetColor(pCc->pGolScheme->CommonBkColor); if(!Bar(pCc->left, pCc->top, pCc->right, pCc->bottom)) return (0); return (1); } state = BOX_DRAW; case BOX_DRAW: if(GetState(pCc, CC_DRAW)) { GOLPanelDraw ( pCc->left, pCc->top, pCc->right, pCc->bottom, pCc->pGolScheme->Color0, pCc->pGolScheme->EmbossDkColor, pCc->pGolScheme->EmbossLtColor, NULL, GOL_EMBOSS_SIZE ); } else { state = BAR_DRAW; goto bar_draw; } state = RUN_DRAW; case RUN_DRAW: if(!GOLPanelDrawTsk()) { return (0); } // DRAWING IS DONE state = REMOVE; return (1); } }
template<int I> void Foo () { const int cst = global; auto lam0 = [&]() -> void { auto lam1 = [&]() -> void { cst; }; Bar (cst); }; }
int Baz (int const *ptr, int *ptr2) { Baz (ptr2); // { dg-error "ambiguous" } Bar (ptr2); // { dg-error "ambiguous" } Foo (ptr2); // { dg-error "ambiguous" } Qux (ptr2); // { dg-error "ambiguous" } return 0; }
void Foo(int number) { Bar(); if (::testing::Test::HasFatalFailure()) return FailTest(); ASSERT_TRUE(number != 3); }
void Foo( int a, int b, int c, int d) { printf( "Foo: calling Bar...\n"); Bar( a ); printf( "Foo: %d, %d, %d, %d\n", a,b,c,d ); }
int main() { std::vector<Bar> v; v.push_back(Bar()); Bar b = fcn3(v.begin(), v.end()); ; ; }
int main(){ int i = 1; i = 1; while(i < 0) i++; i = Foo(Bar()) + 5; return 0; }
int main() { // Foo foo = anotherWay(); // foo's pointer now points to something on the stack that is not there any more. // foo.print(); // Bar bar = anotherBar(); Bar bar = Bar("Hundeprute"); bar.print(); }
void VScroller::Redraw(IntCoord x1, IntCoord y1, IntCoord x2, IntCoord y2) { IntCoord bot; int height; Background(x1, y1, x2, y2); GetBarInfo(shown, bot, height); Bar(bot, height); Outline(bot, height); }
void HScroller::Redraw(IntCoord x1, IntCoord y1, IntCoord x2, IntCoord y2) { IntCoord left; int width; Background(x1, y1, x2, y2); GetBarInfo(shown, left, width); Bar(left, width); Outline(left, width); }
/************************************************************************ Function: void CreateAnimation(void) Overview: Creates the animation screen. Input: none Output: none ************************************************************************/ void CreateAnimation(void) { SHORT j, height, endPoint; // free memory for the objects in the previous linked list and start new list GOLFree(); SetColor(SCREEN_BACKGROUND_COLOR); ClearDevice(); // draw the band of lines with increasing thickness background of the demo height = 13; endPoint = GetMaxY() - 35; SetColor(RGB565CONVERT(0x4C, 0x8E, 0xFF)); for(j = 2; j <= endPoint; j += (height + 6)) { WAIT_UNTIL_FINISH(Bar(0, j, GetMaxX(), j + height)); if(height <= 0) height = 0; else height -= 1; } pPicture = PictCreate ( ID_PICTURE1, // ID PICTURE_XINDENT, PICTURE_YINDENT, PICTURE_XINDENT + PICTURE_WIDTH - 1, PICTURE_YINDENT + PICTURE_HEIGHT - 1, PICT_DRAW, // will be dislayed, has frame 2, // scale factor is x1 (void *) &Engine1, // bitmap altScheme ); // default GOL scheme pMeter = MtrCreate ( ID_METER2, (2 * PICTURE_XINDENT + PICTURE_WIDTH), PICTURE_YINDENT - 20, (2 * (PICTURE_XINDENT + PICTURE_WIDTH)), PICTURE_YINDENT + PICTURE_HEIGHT + 20, MTR_DRAW | MTR_RING | MTR_ACCURACY, // draw normal meter object MAX_METER_VALUE, // set initial value 0, MAX_METER_VALUE, // set range (void *) &GOLFontDefault, // Title font to be used (void *) &GOLMediumFont, // Value font to be used MeterStr, // meterScheme ); // alternative GOL scheme //pMeter->pTitleFont = (void*)&GOLFontDefault; //pMeter->pValueFont = (void*)&GOLMediumFont; // create the demo navigation/control buttons CreateCtrlButtons(ExitStr, ScaleStr, LeftArrowStr, RightArrowStr); }
void Bar( int a, int b, int c, int d ) { if ( done == 0 ) { done = 1; Bar(a+20, b+20, c+20, d+20); } printf( "Bar: %d, %d, %d, %d\n", a,b,c,d ); }
int main() { unsigned long sp; sp = getSP(); printf( "Application stack pointer = 0x%lx\n", sp ); Bar(); return 0; }
void VScroller::Update() { IntCoord oldbottom, oldtop, newbottom, newtop; int oldheight, newheight; Perspective* p; if (canvas == nil) { return; } p = view; GetBarInfo(shown, oldbottom, oldheight); GetBarInfo(p, newbottom, newheight); if (oldbottom != newbottom || oldheight != newheight) { oldtop = oldbottom+oldheight-1; newtop = newbottom+newheight-1; if (oldtop >= newbottom && newtop >= oldbottom) { if (oldtop > newtop) { Background(inset, newtop+1, xmax-inset, oldtop); Border(newtop); } else if (oldtop < newtop) { Bar(oldtop, newtop-oldtop); Sides(oldtop, newtop); Border(newtop); } if (oldbottom > newbottom) { Bar(newbottom+1, oldbottom-newbottom); Sides(newbottom, oldbottom); Border(newbottom); } else if (oldbottom < newbottom) { Background(inset, oldbottom, xmax-inset, newbottom-1); Border(newbottom); } } else { Background(inset, oldbottom, xmax-inset, oldtop); Bar(newbottom, newheight); Outline(newbottom, newheight); } } *shown = *p; }
void HScroller::Update() { IntCoord oldleft, oldright, newleft, newright; int oldwidth, newwidth; Perspective* p; if (canvas == nil) { return; } p = view; GetBarInfo(shown, oldleft, oldwidth); GetBarInfo(p, newleft, newwidth); if (oldleft != newleft || oldwidth != newwidth) { oldright = oldleft+oldwidth-1; newright = newleft+newwidth-1; if (oldright >= newleft && newright >= oldleft) { if (oldright > newright) { Background(newright+1, inset, oldright, ymax-inset); Border(newright); } else if (oldright < newright) { Bar(oldright, newright-oldright); Sides(oldright, newright); Border(newright); } if (oldleft > newleft) { Bar(newleft+1, oldleft-newleft); Sides(newleft, oldleft); Border(newleft); } else if (oldleft < newleft) { Background(oldleft, inset, newleft-1, ymax-inset); Border(newleft); } } else { Background(oldleft, inset, oldright, ymax-inset); Bar(newleft, newwidth); Outline(newleft, newwidth); } } *shown = *p; }
// CHECK: define void @_Z1g3Foo(%struct.Foo* %foo) void g(Foo foo) { // CHECK: call void @_ZN3BarC1Ev // CHECK: @_ZNK3BarcvRK3FooEv // CHECK: call void @_Z1f3Foo f(Bar()); // CHECK: call void @_ZN3FooC1Ev // CHECK: call void @_Z1f3Foo f(Foo()); // CHECK: call void @_ZN3FooC1ERKS_ // CHECK: call void @_Z1f3Foo f(foo); // CHECK: ret }
/***************************************** * void PrepareDemoPage(XCHAR *pText) *****************************************/ void PrepareDemoPage(XCHAR *pText) { SetColor(WHITE); Bar(26, 40, GetMaxX()-26, GetMaxY()-1); if ( pText ) { WINDOW * pMainWin = (WINDOW*)GOLFindObject(ID_WINDOW1); WndSetText(pMainWin, pText); SetState(pMainWin, WND_DRAW_TITLE); WndDraw(pMainWin); } }
void Spectrograph::updateBars() { m_bars.fill(Bar()); FrequencySpectrum::const_iterator i = m_spectrum.begin(); const FrequencySpectrum::const_iterator end = m_spectrum.end(); for ( ; i != end; ++i) { const FrequencySpectrum::Element e = *i; if (e.frequency >= m_lowFreq && e.frequency < m_highFreq) { Bar &bar = m_bars[barIndex(e.frequency)]; bar.value = qMax(bar.value, e.amplitude); bar.clipped |= e.clipped; } } update(); }
//刷新频谱bar void Spectrograph::updateBars() { m_bars.fill(Bar()); //遍历频谱参数 for (FrequencySpectrum::const_iterator iter = m_spectrum.begin(); iter != m_spectrum.end(); ++iter) { const FrequencySpectrum::Element element = *iter; //如果进过快速傅里叶过的频谱参数大于等于频谱下界小于频谱上界则进行以下操作 if (element.frequency >= m_lowFreq && element.frequency < m_highFreq) { Bar &bar = m_bars[barIndex(element.frequency)]; bar.value = qMax(bar.value, element.amplitude); //频谱bar振幅范围 bar.clipped |= element.clipped; } } update(); }
TEST(MatchingContainers, Foo) { MockFoo foo; EXPECT_CALL(foo, Bar(ElementsAre(1, Gt(0), _, 5))); EXPECT_CALL(foo, Bar(UnorderedElementsAre(2, 3))); const vector<int> a{1, 2, 3, 5}; foo.Bar(a); const vector<int> b{3, 2}; foo.Bar(b); }