本文整理汇总了C++中Visitor::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Visitor::clear方法的具体用法?C++ Visitor::clear怎么用?C++ Visitor::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Visitor
的用法示例。
在下文中一共展示了Visitor::clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
Action::visit(Visitor& visitor) const
{
switch (m_command)
{
case Clear: visitor.clear(); break;
case Insert: visitor.insert(m_level, m_key1); break;
case Replace: visitor.replace(m_level, m_key1, m_key2); break;
case Remove: visitor.remove(m_level, m_key1, m_key2); break;
case Finish: visitor.finish(m_level); break;
}
}
示例2: main
int main()
{
// 1 + 1
// vector<string> l;
// l.push_back("1");
// l.push_back("+");
// l.push_back("1");
// 2 * ( 1 + 1 )
vector<string> l;
l.push_back("2");
l.push_back("*");
l.push_back("(");
l.push_back("1");
l.push_back("+");
l.push_back("1");
l.push_back(")");
l.push_back("+");
l.push_back("123123");
LexerStream stream(l);
Parser parser;
parser.expr(&stream);
// cout << endl;
// cout << parser.code.front();
long usetime = timeTick([&](){
int count = 100000;
while(count-- != 0) {
int r = 2 * (1+1) + 123123;
(void)r;
}
});
cout << endl;
cout << "usetime:" << usetime;
cout << endl;
usetime = timeTick([&](){
int count = 100000;
Calculator calculator;
while(count-- != 0) {
calculator.code = parser.code;
calculator.result();
}
});
cout << endl;
cout << "usetime:" << usetime;
cout << endl;
//---------------------------
usetime = timeTick([&](){
int count = 100000;
Visitor visitor;
while(count-- != 0) {
visitor.clear();
parser.asttree.astNode->accept(&visitor);
}
});
cout << endl;
cout << "usetime:" << usetime;
cout << endl;
// Calculator calculator;
// calculator.code = parser.code;
// cout << calculator.result();
// Visitor visitor;
// parser.asttree.astNode->accept(&visitor);
// std::cout << std::endl;
// visitor.print();
}