Shared Pointer

__attribute__((noinline))
int Process(std::shared_ptr<Foo> p) {
  return p->compute();
}

for (auto& p : arr) {
  sum += Process(p);
}
^ This is Faster?
__attribute__((noinline))
int Process(Foo* p) {
  return p->compute();
}

for (auto& p : arr) {
  sum += Process(p.get());
}
^ This is Faster?

* The benchmark is run under AMD Ryzen 9.

* For the full benchmark code, please refer here.

* For illustration purposes only, see FAQ for more details.