Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page 193: Unused argument in "new" placement operator. #225

Open
dcechano opened this issue Jul 2, 2024 · 0 comments
Open

Page 193: Unused argument in "new" placement operator. #225

dcechano opened this issue Jul 2, 2024 · 0 comments

Comments

@dcechano
Copy link

dcechano commented Jul 2, 2024

On page 193, you introduce the placement operators. Specifically, you demonstrate how to use new operator and provide the function signature as void* operator new(size_t, void*). However, when use of the function is demonstrated it is demonstrated as:

    auto point1 = new(&data[0 * point_size]) Point{};
    auto point2 = new(&data[1 * point_size]) Point{};
    auto point3 = new(&data[2 * point_size]) Point{};

The provided signature is not consistent with the demonstrated use. Specifically, there is no size_t passed in as an argument as the function signature stipulates there should. This was confusing. Why is there no size_t passed in when the function is called? Is it optional? I ran the code, and it compiles without issues or warning, but the book does not explain what is going on here, nor even acknowledge the inconsistency. As a book that is teaching the language and assumes no prior knowledge with c++, this seems like an oversight.

In any case, I am enjoying the book so far. I just wanted to point this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant