I know it accepts a reference to the allocator, but then what? Does it create a copy of it or keep storing it as a reference? I couldn't find that out with a debugger.
Asked
Active
Viewed 55 times
0
-
3Just check the [documentation](https://www.boost.org/doc/libs/1_56_0/libs/smart_ptr/make_shared.html#functions): `allocate_shared` uses **a copy of `a`** to allocate memory. I believe the constant reference parameter itself cannot be used, since `allocate` can be a non-const member function. – Daniel Langr Jun 02 '20 at 11:09
-
@DanielLangr I've checked the new version of [documentation](https://www.boost.org/doc/libs/1_73_0/libs/smart_ptr/doc/html/smart_ptr.html#make_shared) and it says: "Uses a **rebound** copy of a". What does that mean? – Nikita128 Jun 02 '20 at 11:28
-
2See, e.g., [this question](https://stackoverflow.com/q/14148756/580083), where you find explanations what allocator-rebinding means. Basically, it just instantiates an allocator from the same allocator class template but with different value type (its template argument). – Daniel Langr Jun 02 '20 at 11:37