#include <iostream>
#include <future>
#include <chrono>
#include <memory>
using namespace std;
using std::cout;
using std::cin;
using std::endl;
int bar() { return 42; }
int main()
{
auto s2 = std::chrono::steady_clock::now();
auto sh_ptr1 = std::make_shared<std::packaged_task<int()> >(bar);
auto e2 = std::chrono::steady_clock::now();
auto s1 = std::chrono::steady_clock::now();
std::packaged_task<int()> pt1(bar);
auto e1 = std::chrono::steady_clock::now();
auto first = std::chrono::duration_cast<std::chrono::nanoseconds>(e1-s1);
auto second = std::chrono::duration_cast<std::chrono::nanoseconds>(e2-s2);
cout << "Regular: " << first.count() << endl
<< "Make shared: " << second.count() << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnV0dXJlPgojaW5jbHVkZSA8Y2hyb25vPgojaW5jbHVkZSA8bWVtb3J5PgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnVzaW5nIHN0ZDo6Y291dDsKdXNpbmcgc3RkOjpjaW47CnVzaW5nIHN0ZDo6ZW5kbDsKCmludCBiYXIoKSB7IHJldHVybiA0MjsgfQoKaW50IG1haW4oKQp7CiAgICBhdXRvIHMyID0gc3RkOjpjaHJvbm86OnN0ZWFkeV9jbG9jazo6bm93KCk7CiAgICBhdXRvIHNoX3B0cjEgPSBzdGQ6Om1ha2Vfc2hhcmVkPHN0ZDo6cGFja2FnZWRfdGFzazxpbnQoKT4gPihiYXIpOwogICAgYXV0byBlMiA9IHN0ZDo6Y2hyb25vOjpzdGVhZHlfY2xvY2s6Om5vdygpOwoKICAgIGF1dG8gczEgPSBzdGQ6OmNocm9ubzo6c3RlYWR5X2Nsb2NrOjpub3coKTsKICAgIHN0ZDo6cGFja2FnZWRfdGFzazxpbnQoKT4gcHQxKGJhcik7CiAgICBhdXRvIGUxID0gc3RkOjpjaHJvbm86OnN0ZWFkeV9jbG9jazo6bm93KCk7CgogICAgYXV0byBmaXJzdCA9IHN0ZDo6Y2hyb25vOjpkdXJhdGlvbl9jYXN0PHN0ZDo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