ETLCPP / etl

Embedded Template Library
https://www.etlcpp.com
MIT License
2.17k stars 388 forks source link

Legacy emplace operator having `const &` arguments #752

Open Un-done opened 1 year ago

Un-done commented 1 year ago

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 commented 1 year ago

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

Un-done commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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.