Affects Version/s: 0.11.0
Fix Version/s: None
Component/s: C++ - Compiler
I'm a little confused about the behavior of optional fields with default values in a struct.
If I define a struct like this:
The cpp generator will generate codes like this:
Even though the server side does not receive any Message from the client, it generates a Message with Message.msg_type = "raw" and Message.__isset.msg_type = true.
However, the related part of the document says that "only fields with this flag set are written, and conversely the flag is only set when a field value has been read from the input stream" (see Thrift IDL)
So I think for a field with default value, its __isset flag should still be false if its value is not read from a input stream.
I want to give a default value to the field but I also want to distinguish the situation that users don't set it (for example, users use an older client that does not have the Message struct at all)
Can anybody explain about the reason of this design and tell me how can I implement the requirement mentioned above? Appreciate for that.