vendredi 13 mars 2015

Passing unique_ptr vs raw_ptr?


What is more common in your experience: func1() or funct2()?



void func1(unique_ptr<Bar>& bar) { /* alter pointed to object's attributes */ }

void func2(Bar* const bar) { /* alter pointed to object's attributes */ }

class Foo
{
unique_ptr<Bar> bar;
void mutate_bar1(){ func1(bar); }
void mutate_bar2(){ func2(bar.get()); }
}



Aucun commentaire:

Enregistrer un commentaire