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

Legacy emplace operator having const & arguments #752

Open
Un-done opened this issue Aug 31, 2023 · 4 comments
Open

Legacy emplace operator having const & arguments #752

Un-done opened this issue Aug 31, 2023 · 4 comments
Assignees

Comments

@Un-done
Copy link
Contributor

Un-done commented Aug 31, 2023

I need to pass a non-const reference to my class on construction, but emplace takes arguments as const &. My guess is, the const doesn't need to be there.

Works for C++11, so I guess it should also be ok for C++03.
Godbolt

@jwellbelove
Copy link
Contributor

Emplace could be changed have both const and non-const reference parameters.

@Un-done
Copy link
Contributor Author

Un-done commented Sep 1, 2023

Yeah, I remembered the cases where const has to be there. So duplication seems unavoidable.
I'm not sure if it makes sense for every emplace, otherwise I could do the grunt work. My usecase atm would only involve etl::variant.

@jwellbelove
Copy link
Contributor

jwellbelove commented Sep 1, 2023

The C++03 compatible emplace functions in the ETL are not really the same as those in C++11.
C++11's take 'universal' references, while those for C++03 must be a specific type.
They are also limited in the number of parameters, as every variation must be defined.

@Un-done
Copy link
Contributor Author

Un-done commented Sep 13, 2023

I think there was some misunderstanding, but that doesn't matter.

To come back to the issue:

Emplace could be changed have both const and non-const reference parameters.

I agree that this would solve my issue.
Let me know if I can help.

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

No branches or pull requests

2 participants