ThePhD / sol2

Sol3 (sol2 v3.0) - a C++ <-> Lua API wrapper with advanced features and top notch performance - is here, and it's great! Documentation:
http://sol2.rtfd.io/
MIT License
4.12k stars 500 forks source link

Unwanted function argument copying starting from v3.3.0 #1438

Open niello opened 1 year ago

niello commented 1 year ago

In push_reference, where the use_reference_tag is calculated, there is a change made in v3.3.0: meta::neg<std::is_const<T>> -> meta::neg<std::is_const<std::remove_reference_t<T>>>

Due to this change, const T& args meet the reference condition no more, and now they are copied for the call. The first issue here is that some big and heavy objects are copied although we explicitly pass them as const references and don't either want or expect copying to happen. The second issue is inability to pass refcounted objects without making a new reference, which is desired sometimes and was possible before the change.

roman-orekhov commented 1 year ago

Looks like it is by initial design documented here Also related #1365 with declined PR