-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
Need C++11 move semantics in the generated code #2791
Comments
see #2780 |
We are currently experimenting with this inside Google and evaluating the effects on binary size, compile times, runtime performance, etc. This isn't political so much as technical; we need to ensure that this doesn't have adverse effects when deployed at scale across our large code base. If these experiments go well, this change should show up in one of our merges from our internal code-base. |
Perhaps stating the obvious:
This will appease both camps - the ones who use the modern compiles as well as the rest, that are stuck with old distros. |
The plan is to have protoc generate movable constructors by default (guarded by #ifdef CXX11). We are already experimenting this inside Google and I would rather not take a detour here. For options, we are generally against them because they complicate our code base, build scripts and more importantly complicate user API/interface. Options also tend to cause interoperability problems. For example, what if an user uses a protoc built with --with-c++11 but depends on a protobuf library built without this --with-c++11 flag? It really doesn't worth the trouble to add options for a feature that we will soon have anyway. |
BTW, in addition to what I initially did in #2778, the generated code needs the following:
|
@os12 Move-aware setters for string fields are already there: The next release 3.4.0 will make generated proto messages movable. |
I notice this has landed in the 3.4 branch. Thanks! I noticed a little problem though: there are move constructors for generated messages, but not for message containers ( With the original proposal there was concern about code bloat because there's a move constructor and assignment for every generated message type, which there can be many of in an application. This worry doesn't apply to the containers, because we're just talking about four non-templated functions (move constructor and move assignment for the two classes), possibly inlined, plus two templated functions that are only instantiated if they're used. |
I've realised another problem: The move constructor is not declared Of course the workarounds for this are the same as before move constructors were introduced: replace |
What about such C++11 feature as 'enum class' ? |
@arthur-tacca @denisiussion Can you create separate issues for RepeatedField/noexcept/enum class? |
@xfxyjwf Apologies that I never made an issue for move constructors/assignment for RepeatedField and co. I notice someone has added them anyway, so many thanks for that. 👍 |
It is 2017 and the protobuf-generated code needs the following C++11 features:
The patch is trivial, see PR #2778. Yet this thing seems to be stuck due to political reasons... Opening an issue to track the progress.
The text was updated successfully, but these errors were encountered: