コード例 #1
0
void moveToConstReferenceNegatives() {
  // No warning when actual move takes place.
  MoveSemantics move_semantics;
  callByValue(std::move(move_semantics));
  callByRValueRef(std::move(move_semantics));
  MoveSemantics other(std::move(move_semantics));
  other = std::move(move_semantics);

  // No warning if std::move() not used.
  NoMoveSemantics no_move_semantics;
  callByConstRef(no_move_semantics);

  // No warning if instantiating a template.
  templateFunction(no_move_semantics);

  // No warning inside of macro expansions.
  M3(NoMoveSemantics, no_move_semantics);

  // No warning inside of macro expansion, even if the macro expansion is inside
  // a lambda that is, in turn, an argument to a macro.
  CALL([no_move_semantics] { M3(NoMoveSemantics, no_move_semantics); });

  auto lambda = [] {};
  auto lambda2 = std::move(lambda);
}
コード例 #2
0
void DynamicData()
{
	/* 
	MyComplexType* pdata = new MyComplexType();
	pdata->data = 'a';
	delete pdata;
	*/
	MyComplexTypeRef<MyComplexType> rdata = new MyComplexType();
	rdata->data = 'a';

	MyComplexTypeRefT rdata2(nullptr);
	rdata2 = rdata; // zuweisungsoperator!!!
	callByValue(rdata); // call by value copy constructor!!

	MyComplexTypeRef<> rIntData = new int();
	auto retValue = returnValue<MyComplexType>();

	MyComplexTypeRef<MyComplexType> rIntArray(new MyComplexType[5], [](MyComplexType* d) {delete[] d; });
}