本文整理汇总了C++中NodeRefPtr::swap方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeRefPtr::swap方法的具体用法?C++ NodeRefPtr::swap怎么用?C++ NodeRefPtr::swap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeRefPtr
的用法示例。
在下文中一共展示了NodeRefPtr::swap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: baseNode
static bool
Test_TfRefPtr()
{
TestConversions();
TestNullptrComparisons();
NodeRefPtr chain1 = MakeChain(10);
NodeRefPtr chain2 = MakeChain(5);
NodePtr gChain1 = chain1;
NodePtr gChain2 = chain2;
TF_AXIOM(chain1->GetLength() == 10);
TF_AXIOM(chain2->GetLength() == 5);
TF_AXIOM(gChain1->GetLength() == 10);
TF_AXIOM(gChain2->GetLength() == 5);
std::cout
<< "total nodes (should be 15): "
<< Node::GetTotalNodeCount() << std::endl;
NodeRefPtr start = Node::New();
start->SetChild(chain1);
chain1 = TfNullPtr;
TF_AXIOM(gChain1->GetLength() == 10);
TF_AXIOM(start->GetLength() == 11);
std::cout
<< "total nodes (should be one more than previous): "
<< Node::GetTotalNodeCount() << std::endl;
start->SetChild(gChain2);
chain2 = TfNullPtr;
TF_AXIOM(start->GetLength() == 6);
TF_AXIOM(!gChain1);
TF_AXIOM(gChain2);
TF_AXIOM(start->GetLength() == start->GetTail()->GetRevLength());
std::cout
<< "total nodes (should be 10 less than last): "
<< Node::GetTotalNodeCount() << std::endl;
start = TfNullPtr;
TF_AXIOM(!gChain1);
TF_AXIOM(!gChain2);
std::cout
<< "total nodes (should be zero): "
<< Node::GetTotalNodeCount() << std::endl;
TF_AXIOM(Node::GetTotalNodeCount() == 0);
chain1 = MakeChain(5);
gChain2 = chain2 = MakeChain(5);
chain1->GetTail()->SetChild(chain2);
TF_AXIOM(gChain2->GetRevLength() == 6);
chain1 = TfNullPtr;
TF_AXIOM(gChain2->GetRevLength() == 1);
chain2 = TfNullPtr;
TF_AXIOM(!gChain2);
TF_AXIOM(Node::GetTotalNodeCount() == 0);
SuperNodeRefPtr superPtr = SuperNode::New();
NodeRefPtr basePtr = superPtr;
NodePtr baseBackPtr = basePtr;
TF_AXIOM(TfDynamic_cast<SuperNodeRefPtr>(basePtr) == superPtr);
TF_AXIOM(TfSafeDynamic_cast<SuperNodeRefPtr>(basePtr) == superPtr);
TF_AXIOM(TfDynamic_cast<SuperNodePtr>(baseBackPtr) == superPtr);
TF_AXIOM(TfSafeDynamic_cast<SuperNodePtr>(baseBackPtr) == superPtr);
// Test swap
{
const NodeRefPtr n1 = Node::New();
const NodeRefPtr n2 = Node::New();
NodeRefPtr a = n1;
NodeRefPtr b = n2;
TF_AXIOM(a);
TF_AXIOM(b);
TF_AXIOM(a != b);
TF_AXIOM(a == n1);
TF_AXIOM(b == n2);
a.swap(b);
TF_AXIOM(a == n2);
TF_AXIOM(b == n1);
// Test self-swap
a.swap(a);
TF_AXIOM(a == n2);
b.swap(b);
TF_AXIOM(b == n1);
}
//.........这里部分代码省略.........