#include <utility>
#include <iostream>
using namespace std;
int main()
{
int myObject = 1;
int myOldValue = 0.0;
myOldValue = exchange(myObject, 9);
cout << myOldValue << " " << myObject;
cout << endl;
return 0;
}
// Output: 1 9
Reference: http://en.cppreference.com/w/cpp/utility/exchange
Monday, December 11, 2017
C++14: std::exchange()
C++14 added the template function std::exchange(). Here is an example:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment