Skip to content

any issue replacing pointer with unique pointer in this example? #1669

Closed Answered by uNetworkingAB
ThomasCartier asked this question in Q&A
Discussion options

You must be logged in to vote

The size of a pointer is 8 bytes, same for unique_ptr. The size of std::string is 32 bytes. The size of std::function is 32 bytes.

This means that you'd pay allocation cost in your fast path with your change. The whole point is to have a fast fast path and a slow slow path. Whatever you do (unique_ptr is probably fine), you don't want to incur a cost in your fast path.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by ThomasCartier
Comment options

You must be logged in to vote
2 replies
@uNetworkingAB
Comment options

@ThomasCartier
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants