From 159d73146c945bfdb7cfe08a80e48578bd94acde Mon Sep 17 00:00:00 2001 From: TJ Yin Date: Tue, 17 Dec 2024 13:33:47 -0800 Subject: [PATCH] Always use "has_value()" method in getters_setters.mustache Summary: Currently the usages are inconsistently. Reviewed By: yoney Differential Revision: D67281805 fbshipit-source-id: c0cd5d58d867983f14dbf7ea30e1d491b2745d30 --- .../module_types_h/getters_setters.mustache | 8 +- .../out/cpp2/gen-cpp2/module_types.h | 8 +- .../out/cpp2/gen-cpp2/module_types.h | 20 ++--- .../out/cpp2/gen-cpp2/module_types.h | 8 +- .../out/cpp2/gen-cpp2/simple_types.h | 76 +++++++++---------- .../out/cpp2/gen-cpp2/module_types.h | 4 +- .../fatal/out/cpp2/gen-cpp2/module_types.h | 12 +-- .../out/cpp2/gen-cpp2/module_types.h | 64 ++++++++-------- .../out/cpp2/gen-cpp2/module_types.h | 4 +- .../out/cpp2/gen-cpp2/module_types.h | 16 ++-- .../gen-cpp2/extra_services_types.h | 8 +- .../mixin/out/cpp2/gen-cpp2/module_types.h | 4 +- .../nimble/out/cpp2/gen-cpp2/module_types.h | 8 +- .../out/cpp2/gen-cpp2/module_types.h | 32 ++++---- .../py3/out/cpp2/gen-py3cpp/module_types.h | 4 +- .../out/cpp2/gen-cpp2/module_types.h | 4 +- .../gen-cpp2/serialized_dep_types.h | 16 ++-- .../out/cpp2/gen-cpp2/module_types.h | 4 +- .../gen-cpp2/module_structs_types.h | 4 +- .../out/cpp2/gen-cpp2/module_types.h | 16 ++-- .../out/cpp2/gen-cpp2/module_types.h | 12 +-- 21 files changed, 166 insertions(+), 166 deletions(-) diff --git a/thrift/compiler/generate/templates/cpp2/module_types_h/getters_setters.mustache b/thrift/compiler/generate/templates/cpp2/module_types_h/getters_setters.mustache index 05627c9c2c0..f53069568f1 100644 --- a/thrift/compiler/generate/templates/cpp2/module_types_h/getters_setters.mustache +++ b/thrift/compiler/generate/templates/cpp2/module_types_h/getters_setters.mustache @@ -22,13 +22,13 @@ {{> common/field_docblock}} [[deprecated("Use `FOO.{{field:cpp_name}}().value();` instead of `FOO.get_{{field:cpp_name}}();`")]] const {{type:cpp_type}}* get_{{field:cpp_name}}() const& { - return {{field:cpp_name}}_ref() ? std::addressof({{field:cpp_storage_name}}) : nullptr; + return {{field:cpp_name}}_ref().has_value() ? std::addressof({{field:cpp_storage_name}}) : nullptr; } {{> common/field_docblock}} [[deprecated("Use `FOO.{{field:cpp_name}}().value();` instead of `FOO.get_{{field:cpp_name}}();`")]] {{type:cpp_type}}* get_{{field:cpp_name}}() & { - return {{field:cpp_name}}_ref() ? std::addressof({{field:cpp_storage_name}}) : nullptr; + return {{field:cpp_name}}_ref().has_value() ? std::addressof({{field:cpp_storage_name}}) : nullptr; } {{> common/field_docblock}} [[deprecated("Use `FOO.{{field:cpp_name}}().value();` instead of `FOO.get_{{field:cpp_name}}();`")]] @@ -53,13 +53,13 @@ {{> common/field_docblock}} [[deprecated("Use `FOO.{{field:cpp_name}}().value();` instead of `FOO.get_{{field:cpp_name}}();`")]] const {{type:cpp_type}}* get_{{field:cpp_name}}() const& { - return {{field:cpp_name}}_ref() ? std::addressof({{field:cpp_storage_name}}) : nullptr; + return {{field:cpp_name}}_ref().has_value() ? std::addressof({{field:cpp_storage_name}}) : nullptr; } {{> common/field_docblock}} [[deprecated("Use `FOO.{{field:cpp_name}}().value();` instead of `FOO.get_{{field:cpp_name}}();`")]] {{type:cpp_type}}* get_{{field:cpp_name}}() & { - return {{field:cpp_name}}_ref() ? std::addressof({{field:cpp_storage_name}}) : nullptr; + return {{field:cpp_name}}_ref().has_value() ? std::addressof({{field:cpp_storage_name}}) : nullptr; } {{> common/field_docblock}} [[deprecated("Use `FOO.{{field:cpp_name}}().value();` instead of `FOO.get_{{field:cpp_name}}();`")]] diff --git a/thrift/compiler/test/fixtures/complex-struct/out/cpp2/gen-cpp2/module_types.h b/thrift/compiler/test/fixtures/complex-struct/out/cpp2/gen-cpp2/module_types.h index ba673407f35..1168f3f9e26 100644 --- a/thrift/compiler/test/fixtures/complex-struct/out/cpp2/gen-cpp2/module_types.h +++ b/thrift/compiler/test/fixtures/complex-struct/out/cpp2/gen-cpp2/module_types.h @@ -9108,13 +9108,13 @@ class FOLLY_EXPORT optXcep : public virtual apache::thrift::TException { /** Glean { "field": "message" } */ [[deprecated("Use `FOO.message().value();` instead of `FOO.get_message();`")]] const ::std::string* get_message() const& { - return message_ref() ? std::addressof(__fbthrift_field_message) : nullptr; + return message_ref().has_value() ? std::addressof(__fbthrift_field_message) : nullptr; } /** Glean { "field": "message" } */ [[deprecated("Use `FOO.message().value();` instead of `FOO.get_message();`")]] ::std::string* get_message() & { - return message_ref() ? std::addressof(__fbthrift_field_message) : nullptr; + return message_ref().has_value() ? std::addressof(__fbthrift_field_message) : nullptr; } /** Glean { "field": "message" } */ [[deprecated("Use `FOO.message().value();` instead of `FOO.get_message();`")]] @@ -9131,13 +9131,13 @@ class FOLLY_EXPORT optXcep : public virtual apache::thrift::TException { /** Glean { "field": "errorCode" } */ [[deprecated("Use `FOO.errorCode().value();` instead of `FOO.get_errorCode();`")]] const ::std::int32_t* get_errorCode() const& { - return errorCode_ref() ? std::addressof(__fbthrift_field_errorCode) : nullptr; + return errorCode_ref().has_value() ? std::addressof(__fbthrift_field_errorCode) : nullptr; } /** Glean { "field": "errorCode" } */ [[deprecated("Use `FOO.errorCode().value();` instead of `FOO.get_errorCode();`")]] ::std::int32_t* get_errorCode() & { - return errorCode_ref() ? std::addressof(__fbthrift_field_errorCode) : nullptr; + return errorCode_ref().has_value() ? std::addressof(__fbthrift_field_errorCode) : nullptr; } /** Glean { "field": "errorCode" } */ [[deprecated("Use `FOO.errorCode().value();` instead of `FOO.get_errorCode();`")]] diff --git a/thrift/compiler/test/fixtures/constants/out/cpp2/gen-cpp2/module_types.h b/thrift/compiler/test/fixtures/constants/out/cpp2/gen-cpp2/module_types.h index 7d327fcab38..c8d070d321f 100644 --- a/thrift/compiler/test/fixtures/constants/out/cpp2/gen-cpp2/module_types.h +++ b/thrift/compiler/test/fixtures/constants/out/cpp2/gen-cpp2/module_types.h @@ -698,13 +698,13 @@ class Internship final { /** Glean { "field": "employer" } */ [[deprecated("Use `FOO.employer().value();` instead of `FOO.get_employer();`")]] const ::cpp2::Company* get_employer() const& { - return employer_ref() ? std::addressof(__fbthrift_field_employer) : nullptr; + return employer_ref().has_value() ? std::addressof(__fbthrift_field_employer) : nullptr; } /** Glean { "field": "employer" } */ [[deprecated("Use `FOO.employer().value();` instead of `FOO.get_employer();`")]] ::cpp2::Company* get_employer() & { - return employer_ref() ? std::addressof(__fbthrift_field_employer) : nullptr; + return employer_ref().has_value() ? std::addressof(__fbthrift_field_employer) : nullptr; } /** Glean { "field": "employer" } */ [[deprecated("Use `FOO.employer().value();` instead of `FOO.get_employer();`")]] @@ -720,13 +720,13 @@ class Internship final { /** Glean { "field": "compensation" } */ [[deprecated("Use `FOO.compensation().value();` instead of `FOO.get_compensation();`")]] const double* get_compensation() const& { - return compensation_ref() ? std::addressof(__fbthrift_field_compensation) : nullptr; + return compensation_ref().has_value() ? std::addressof(__fbthrift_field_compensation) : nullptr; } /** Glean { "field": "compensation" } */ [[deprecated("Use `FOO.compensation().value();` instead of `FOO.get_compensation();`")]] double* get_compensation() & { - return compensation_ref() ? std::addressof(__fbthrift_field_compensation) : nullptr; + return compensation_ref().has_value() ? std::addressof(__fbthrift_field_compensation) : nullptr; } /** Glean { "field": "compensation" } */ [[deprecated("Use `FOO.compensation().value();` instead of `FOO.get_compensation();`")]] @@ -742,13 +742,13 @@ class Internship final { /** Glean { "field": "school" } */ [[deprecated("Use `FOO.school().value();` instead of `FOO.get_school();`")]] const ::std::string* get_school() const& { - return school_ref() ? std::addressof(__fbthrift_field_school) : nullptr; + return school_ref().has_value() ? std::addressof(__fbthrift_field_school) : nullptr; } /** Glean { "field": "school" } */ [[deprecated("Use `FOO.school().value();` instead of `FOO.get_school();`")]] ::std::string* get_school() & { - return school_ref() ? std::addressof(__fbthrift_field_school) : nullptr; + return school_ref().has_value() ? std::addressof(__fbthrift_field_school) : nullptr; } /** Glean { "field": "school" } */ [[deprecated("Use `FOO.school().value();` instead of `FOO.get_school();`")]] @@ -2186,13 +2186,13 @@ class struct4 final { /** Glean { "field": "b" } */ [[deprecated("Use `FOO.b().value();` instead of `FOO.get_b();`")]] const double* get_b() const& { - return b_ref() ? std::addressof(__fbthrift_field_b) : nullptr; + return b_ref().has_value() ? std::addressof(__fbthrift_field_b) : nullptr; } /** Glean { "field": "b" } */ [[deprecated("Use `FOO.b().value();` instead of `FOO.get_b();`")]] double* get_b() & { - return b_ref() ? std::addressof(__fbthrift_field_b) : nullptr; + return b_ref().has_value() ? std::addressof(__fbthrift_field_b) : nullptr; } /** Glean { "field": "b" } */ [[deprecated("Use `FOO.b().value();` instead of `FOO.get_b();`")]] @@ -2208,13 +2208,13 @@ class struct4 final { /** Glean { "field": "c" } */ [[deprecated("Use `FOO.c().value();` instead of `FOO.get_c();`")]] const ::std::int8_t* get_c() const& { - return c_ref() ? std::addressof(__fbthrift_field_c) : nullptr; + return c_ref().has_value() ? std::addressof(__fbthrift_field_c) : nullptr; } /** Glean { "field": "c" } */ [[deprecated("Use `FOO.c().value();` instead of `FOO.get_c();`")]] ::std::int8_t* get_c() & { - return c_ref() ? std::addressof(__fbthrift_field_c) : nullptr; + return c_ref().has_value() ? std::addressof(__fbthrift_field_c) : nullptr; } /** Glean { "field": "c" } */ [[deprecated("Use `FOO.c().value();` instead of `FOO.get_c();`")]] diff --git a/thrift/compiler/test/fixtures/default_values/out/cpp2/gen-cpp2/module_types.h b/thrift/compiler/test/fixtures/default_values/out/cpp2/gen-cpp2/module_types.h index c3ff8540ac4..7a7c05443e6 100644 --- a/thrift/compiler/test/fixtures/default_values/out/cpp2/gen-cpp2/module_types.h +++ b/thrift/compiler/test/fixtures/default_values/out/cpp2/gen-cpp2/module_types.h @@ -685,13 +685,13 @@ class StructWithNoCustomDefaultValues final { /** Glean { "field": "optional_integer" } */ [[deprecated("Use `FOO.optional_integer().value();` instead of `FOO.get_optional_integer();`")]] const ::std::int32_t* get_optional_integer() const& { - return optional_integer_ref() ? std::addressof(__fbthrift_field_optional_integer) : nullptr; + return optional_integer_ref().has_value() ? std::addressof(__fbthrift_field_optional_integer) : nullptr; } /** Glean { "field": "optional_integer" } */ [[deprecated("Use `FOO.optional_integer().value();` instead of `FOO.get_optional_integer();`")]] ::std::int32_t* get_optional_integer() & { - return optional_integer_ref() ? std::addressof(__fbthrift_field_optional_integer) : nullptr; + return optional_integer_ref().has_value() ? std::addressof(__fbthrift_field_optional_integer) : nullptr; } /** Glean { "field": "optional_integer" } */ [[deprecated("Use `FOO.optional_integer().value();` instead of `FOO.get_optional_integer();`")]] @@ -1198,13 +1198,13 @@ class StructWithCustomDefaultValues final { /** Glean { "field": "optional_integer" } */ [[deprecated("Use `FOO.optional_integer().value();` instead of `FOO.get_optional_integer();`")]] const ::std::int32_t* get_optional_integer() const& { - return optional_integer_ref() ? std::addressof(__fbthrift_field_optional_integer) : nullptr; + return optional_integer_ref().has_value() ? std::addressof(__fbthrift_field_optional_integer) : nullptr; } /** Glean { "field": "optional_integer" } */ [[deprecated("Use `FOO.optional_integer().value();` instead of `FOO.get_optional_integer();`")]] ::std::int32_t* get_optional_integer() & { - return optional_integer_ref() ? std::addressof(__fbthrift_field_optional_integer) : nullptr; + return optional_integer_ref().has_value() ? std::addressof(__fbthrift_field_optional_integer) : nullptr; } /** Glean { "field": "optional_integer" } */ [[deprecated("Use `FOO.optional_integer().value();` instead of `FOO.get_optional_integer();`")]] diff --git a/thrift/compiler/test/fixtures/emptiable/out/cpp2/gen-cpp2/simple_types.h b/thrift/compiler/test/fixtures/emptiable/out/cpp2/gen-cpp2/simple_types.h index 4fa2594e389..357687ff46c 100644 --- a/thrift/compiler/test/fixtures/emptiable/out/cpp2/gen-cpp2/simple_types.h +++ b/thrift/compiler/test/fixtures/emptiable/out/cpp2/gen-cpp2/simple_types.h @@ -1218,13 +1218,13 @@ class EmptiableStruct final { /** Glean { "field": "bool_field" } */ [[deprecated("Use `FOO.bool_field().value();` instead of `FOO.get_bool_field();`")]] const bool* get_bool_field() const& { - return bool_field_ref() ? std::addressof(__fbthrift_field_bool_field) : nullptr; + return bool_field_ref().has_value() ? std::addressof(__fbthrift_field_bool_field) : nullptr; } /** Glean { "field": "bool_field" } */ [[deprecated("Use `FOO.bool_field().value();` instead of `FOO.get_bool_field();`")]] bool* get_bool_field() & { - return bool_field_ref() ? std::addressof(__fbthrift_field_bool_field) : nullptr; + return bool_field_ref().has_value() ? std::addressof(__fbthrift_field_bool_field) : nullptr; } /** Glean { "field": "bool_field" } */ [[deprecated("Use `FOO.bool_field().value();` instead of `FOO.get_bool_field();`")]] @@ -1240,13 +1240,13 @@ class EmptiableStruct final { /** Glean { "field": "byte_field" } */ [[deprecated("Use `FOO.byte_field().value();` instead of `FOO.get_byte_field();`")]] const ::std::int8_t* get_byte_field() const& { - return byte_field_ref() ? std::addressof(__fbthrift_field_byte_field) : nullptr; + return byte_field_ref().has_value() ? std::addressof(__fbthrift_field_byte_field) : nullptr; } /** Glean { "field": "byte_field" } */ [[deprecated("Use `FOO.byte_field().value();` instead of `FOO.get_byte_field();`")]] ::std::int8_t* get_byte_field() & { - return byte_field_ref() ? std::addressof(__fbthrift_field_byte_field) : nullptr; + return byte_field_ref().has_value() ? std::addressof(__fbthrift_field_byte_field) : nullptr; } /** Glean { "field": "byte_field" } */ [[deprecated("Use `FOO.byte_field().value();` instead of `FOO.get_byte_field();`")]] @@ -1262,13 +1262,13 @@ class EmptiableStruct final { /** Glean { "field": "short_field" } */ [[deprecated("Use `FOO.short_field().value();` instead of `FOO.get_short_field();`")]] const ::std::int16_t* get_short_field() const& { - return short_field_ref() ? std::addressof(__fbthrift_field_short_field) : nullptr; + return short_field_ref().has_value() ? std::addressof(__fbthrift_field_short_field) : nullptr; } /** Glean { "field": "short_field" } */ [[deprecated("Use `FOO.short_field().value();` instead of `FOO.get_short_field();`")]] ::std::int16_t* get_short_field() & { - return short_field_ref() ? std::addressof(__fbthrift_field_short_field) : nullptr; + return short_field_ref().has_value() ? std::addressof(__fbthrift_field_short_field) : nullptr; } /** Glean { "field": "short_field" } */ [[deprecated("Use `FOO.short_field().value();` instead of `FOO.get_short_field();`")]] @@ -1284,13 +1284,13 @@ class EmptiableStruct final { /** Glean { "field": "int_field" } */ [[deprecated("Use `FOO.int_field().value();` instead of `FOO.get_int_field();`")]] const ::std::int32_t* get_int_field() const& { - return int_field_ref() ? std::addressof(__fbthrift_field_int_field) : nullptr; + return int_field_ref().has_value() ? std::addressof(__fbthrift_field_int_field) : nullptr; } /** Glean { "field": "int_field" } */ [[deprecated("Use `FOO.int_field().value();` instead of `FOO.get_int_field();`")]] ::std::int32_t* get_int_field() & { - return int_field_ref() ? std::addressof(__fbthrift_field_int_field) : nullptr; + return int_field_ref().has_value() ? std::addressof(__fbthrift_field_int_field) : nullptr; } /** Glean { "field": "int_field" } */ [[deprecated("Use `FOO.int_field().value();` instead of `FOO.get_int_field();`")]] @@ -1306,13 +1306,13 @@ class EmptiableStruct final { /** Glean { "field": "long_field" } */ [[deprecated("Use `FOO.long_field().value();` instead of `FOO.get_long_field();`")]] const ::std::int64_t* get_long_field() const& { - return long_field_ref() ? std::addressof(__fbthrift_field_long_field) : nullptr; + return long_field_ref().has_value() ? std::addressof(__fbthrift_field_long_field) : nullptr; } /** Glean { "field": "long_field" } */ [[deprecated("Use `FOO.long_field().value();` instead of `FOO.get_long_field();`")]] ::std::int64_t* get_long_field() & { - return long_field_ref() ? std::addressof(__fbthrift_field_long_field) : nullptr; + return long_field_ref().has_value() ? std::addressof(__fbthrift_field_long_field) : nullptr; } /** Glean { "field": "long_field" } */ [[deprecated("Use `FOO.long_field().value();` instead of `FOO.get_long_field();`")]] @@ -1328,13 +1328,13 @@ class EmptiableStruct final { /** Glean { "field": "float_field" } */ [[deprecated("Use `FOO.float_field().value();` instead of `FOO.get_float_field();`")]] const float* get_float_field() const& { - return float_field_ref() ? std::addressof(__fbthrift_field_float_field) : nullptr; + return float_field_ref().has_value() ? std::addressof(__fbthrift_field_float_field) : nullptr; } /** Glean { "field": "float_field" } */ [[deprecated("Use `FOO.float_field().value();` instead of `FOO.get_float_field();`")]] float* get_float_field() & { - return float_field_ref() ? std::addressof(__fbthrift_field_float_field) : nullptr; + return float_field_ref().has_value() ? std::addressof(__fbthrift_field_float_field) : nullptr; } /** Glean { "field": "float_field" } */ [[deprecated("Use `FOO.float_field().value();` instead of `FOO.get_float_field();`")]] @@ -1350,13 +1350,13 @@ class EmptiableStruct final { /** Glean { "field": "double_field" } */ [[deprecated("Use `FOO.double_field().value();` instead of `FOO.get_double_field();`")]] const double* get_double_field() const& { - return double_field_ref() ? std::addressof(__fbthrift_field_double_field) : nullptr; + return double_field_ref().has_value() ? std::addressof(__fbthrift_field_double_field) : nullptr; } /** Glean { "field": "double_field" } */ [[deprecated("Use `FOO.double_field().value();` instead of `FOO.get_double_field();`")]] double* get_double_field() & { - return double_field_ref() ? std::addressof(__fbthrift_field_double_field) : nullptr; + return double_field_ref().has_value() ? std::addressof(__fbthrift_field_double_field) : nullptr; } /** Glean { "field": "double_field" } */ [[deprecated("Use `FOO.double_field().value();` instead of `FOO.get_double_field();`")]] @@ -1372,13 +1372,13 @@ class EmptiableStruct final { /** Glean { "field": "string_field" } */ [[deprecated("Use `FOO.string_field().value();` instead of `FOO.get_string_field();`")]] const ::std::string* get_string_field() const& { - return string_field_ref() ? std::addressof(__fbthrift_field_string_field) : nullptr; + return string_field_ref().has_value() ? std::addressof(__fbthrift_field_string_field) : nullptr; } /** Glean { "field": "string_field" } */ [[deprecated("Use `FOO.string_field().value();` instead of `FOO.get_string_field();`")]] ::std::string* get_string_field() & { - return string_field_ref() ? std::addressof(__fbthrift_field_string_field) : nullptr; + return string_field_ref().has_value() ? std::addressof(__fbthrift_field_string_field) : nullptr; } /** Glean { "field": "string_field" } */ [[deprecated("Use `FOO.string_field().value();` instead of `FOO.get_string_field();`")]] @@ -1395,13 +1395,13 @@ class EmptiableStruct final { /** Glean { "field": "binary_field" } */ [[deprecated("Use `FOO.binary_field().value();` instead of `FOO.get_binary_field();`")]] const ::std::string* get_binary_field() const& { - return binary_field_ref() ? std::addressof(__fbthrift_field_binary_field) : nullptr; + return binary_field_ref().has_value() ? std::addressof(__fbthrift_field_binary_field) : nullptr; } /** Glean { "field": "binary_field" } */ [[deprecated("Use `FOO.binary_field().value();` instead of `FOO.get_binary_field();`")]] ::std::string* get_binary_field() & { - return binary_field_ref() ? std::addressof(__fbthrift_field_binary_field) : nullptr; + return binary_field_ref().has_value() ? std::addressof(__fbthrift_field_binary_field) : nullptr; } /** Glean { "field": "binary_field" } */ [[deprecated("Use `FOO.binary_field().value();` instead of `FOO.get_binary_field();`")]] @@ -1418,13 +1418,13 @@ class EmptiableStruct final { /** Glean { "field": "enum_field" } */ [[deprecated("Use `FOO.enum_field().value();` instead of `FOO.get_enum_field();`")]] const ::apache::thrift::test::MyEnum* get_enum_field() const& { - return enum_field_ref() ? std::addressof(__fbthrift_field_enum_field) : nullptr; + return enum_field_ref().has_value() ? std::addressof(__fbthrift_field_enum_field) : nullptr; } /** Glean { "field": "enum_field" } */ [[deprecated("Use `FOO.enum_field().value();` instead of `FOO.get_enum_field();`")]] ::apache::thrift::test::MyEnum* get_enum_field() & { - return enum_field_ref() ? std::addressof(__fbthrift_field_enum_field) : nullptr; + return enum_field_ref().has_value() ? std::addressof(__fbthrift_field_enum_field) : nullptr; } /** Glean { "field": "enum_field" } */ [[deprecated("Use `FOO.enum_field().value();` instead of `FOO.get_enum_field();`")]] @@ -3181,13 +3181,13 @@ class NotEmptiableStruct final { /** Glean { "field": "byte_field" } */ [[deprecated("Use `FOO.byte_field().value();` instead of `FOO.get_byte_field();`")]] const ::std::int8_t* get_byte_field() const& { - return byte_field_ref() ? std::addressof(__fbthrift_field_byte_field) : nullptr; + return byte_field_ref().has_value() ? std::addressof(__fbthrift_field_byte_field) : nullptr; } /** Glean { "field": "byte_field" } */ [[deprecated("Use `FOO.byte_field().value();` instead of `FOO.get_byte_field();`")]] ::std::int8_t* get_byte_field() & { - return byte_field_ref() ? std::addressof(__fbthrift_field_byte_field) : nullptr; + return byte_field_ref().has_value() ? std::addressof(__fbthrift_field_byte_field) : nullptr; } /** Glean { "field": "byte_field" } */ [[deprecated("Use `FOO.byte_field().value();` instead of `FOO.get_byte_field();`")]] @@ -3203,13 +3203,13 @@ class NotEmptiableStruct final { /** Glean { "field": "short_field" } */ [[deprecated("Use `FOO.short_field().value();` instead of `FOO.get_short_field();`")]] const ::std::int16_t* get_short_field() const& { - return short_field_ref() ? std::addressof(__fbthrift_field_short_field) : nullptr; + return short_field_ref().has_value() ? std::addressof(__fbthrift_field_short_field) : nullptr; } /** Glean { "field": "short_field" } */ [[deprecated("Use `FOO.short_field().value();` instead of `FOO.get_short_field();`")]] ::std::int16_t* get_short_field() & { - return short_field_ref() ? std::addressof(__fbthrift_field_short_field) : nullptr; + return short_field_ref().has_value() ? std::addressof(__fbthrift_field_short_field) : nullptr; } /** Glean { "field": "short_field" } */ [[deprecated("Use `FOO.short_field().value();` instead of `FOO.get_short_field();`")]] @@ -3225,13 +3225,13 @@ class NotEmptiableStruct final { /** Glean { "field": "int_field" } */ [[deprecated("Use `FOO.int_field().value();` instead of `FOO.get_int_field();`")]] const ::std::int32_t* get_int_field() const& { - return int_field_ref() ? std::addressof(__fbthrift_field_int_field) : nullptr; + return int_field_ref().has_value() ? std::addressof(__fbthrift_field_int_field) : nullptr; } /** Glean { "field": "int_field" } */ [[deprecated("Use `FOO.int_field().value();` instead of `FOO.get_int_field();`")]] ::std::int32_t* get_int_field() & { - return int_field_ref() ? std::addressof(__fbthrift_field_int_field) : nullptr; + return int_field_ref().has_value() ? std::addressof(__fbthrift_field_int_field) : nullptr; } /** Glean { "field": "int_field" } */ [[deprecated("Use `FOO.int_field().value();` instead of `FOO.get_int_field();`")]] @@ -3247,13 +3247,13 @@ class NotEmptiableStruct final { /** Glean { "field": "long_field" } */ [[deprecated("Use `FOO.long_field().value();` instead of `FOO.get_long_field();`")]] const ::std::int64_t* get_long_field() const& { - return long_field_ref() ? std::addressof(__fbthrift_field_long_field) : nullptr; + return long_field_ref().has_value() ? std::addressof(__fbthrift_field_long_field) : nullptr; } /** Glean { "field": "long_field" } */ [[deprecated("Use `FOO.long_field().value();` instead of `FOO.get_long_field();`")]] ::std::int64_t* get_long_field() & { - return long_field_ref() ? std::addressof(__fbthrift_field_long_field) : nullptr; + return long_field_ref().has_value() ? std::addressof(__fbthrift_field_long_field) : nullptr; } /** Glean { "field": "long_field" } */ [[deprecated("Use `FOO.long_field().value();` instead of `FOO.get_long_field();`")]] @@ -3269,13 +3269,13 @@ class NotEmptiableStruct final { /** Glean { "field": "float_field" } */ [[deprecated("Use `FOO.float_field().value();` instead of `FOO.get_float_field();`")]] const float* get_float_field() const& { - return float_field_ref() ? std::addressof(__fbthrift_field_float_field) : nullptr; + return float_field_ref().has_value() ? std::addressof(__fbthrift_field_float_field) : nullptr; } /** Glean { "field": "float_field" } */ [[deprecated("Use `FOO.float_field().value();` instead of `FOO.get_float_field();`")]] float* get_float_field() & { - return float_field_ref() ? std::addressof(__fbthrift_field_float_field) : nullptr; + return float_field_ref().has_value() ? std::addressof(__fbthrift_field_float_field) : nullptr; } /** Glean { "field": "float_field" } */ [[deprecated("Use `FOO.float_field().value();` instead of `FOO.get_float_field();`")]] @@ -3291,13 +3291,13 @@ class NotEmptiableStruct final { /** Glean { "field": "double_field" } */ [[deprecated("Use `FOO.double_field().value();` instead of `FOO.get_double_field();`")]] const double* get_double_field() const& { - return double_field_ref() ? std::addressof(__fbthrift_field_double_field) : nullptr; + return double_field_ref().has_value() ? std::addressof(__fbthrift_field_double_field) : nullptr; } /** Glean { "field": "double_field" } */ [[deprecated("Use `FOO.double_field().value();` instead of `FOO.get_double_field();`")]] double* get_double_field() & { - return double_field_ref() ? std::addressof(__fbthrift_field_double_field) : nullptr; + return double_field_ref().has_value() ? std::addressof(__fbthrift_field_double_field) : nullptr; } /** Glean { "field": "double_field" } */ [[deprecated("Use `FOO.double_field().value();` instead of `FOO.get_double_field();`")]] @@ -3313,13 +3313,13 @@ class NotEmptiableStruct final { /** Glean { "field": "string_field" } */ [[deprecated("Use `FOO.string_field().value();` instead of `FOO.get_string_field();`")]] const ::std::string* get_string_field() const& { - return string_field_ref() ? std::addressof(__fbthrift_field_string_field) : nullptr; + return string_field_ref().has_value() ? std::addressof(__fbthrift_field_string_field) : nullptr; } /** Glean { "field": "string_field" } */ [[deprecated("Use `FOO.string_field().value();` instead of `FOO.get_string_field();`")]] ::std::string* get_string_field() & { - return string_field_ref() ? std::addressof(__fbthrift_field_string_field) : nullptr; + return string_field_ref().has_value() ? std::addressof(__fbthrift_field_string_field) : nullptr; } /** Glean { "field": "string_field" } */ [[deprecated("Use `FOO.string_field().value();` instead of `FOO.get_string_field();`")]] @@ -3336,13 +3336,13 @@ class NotEmptiableStruct final { /** Glean { "field": "binary_field" } */ [[deprecated("Use `FOO.binary_field().value();` instead of `FOO.get_binary_field();`")]] const ::std::string* get_binary_field() const& { - return binary_field_ref() ? std::addressof(__fbthrift_field_binary_field) : nullptr; + return binary_field_ref().has_value() ? std::addressof(__fbthrift_field_binary_field) : nullptr; } /** Glean { "field": "binary_field" } */ [[deprecated("Use `FOO.binary_field().value();` instead of `FOO.get_binary_field();`")]] ::std::string* get_binary_field() & { - return binary_field_ref() ? std::addressof(__fbthrift_field_binary_field) : nullptr; + return binary_field_ref().has_value() ? std::addressof(__fbthrift_field_binary_field) : nullptr; } /** Glean { "field": "binary_field" } */ [[deprecated("Use `FOO.binary_field().value();` instead of `FOO.get_binary_field();`")]] @@ -3359,13 +3359,13 @@ class NotEmptiableStruct final { /** Glean { "field": "enum_field" } */ [[deprecated("Use `FOO.enum_field().value();` instead of `FOO.get_enum_field();`")]] const ::apache::thrift::test::MyEnum* get_enum_field() const& { - return enum_field_ref() ? std::addressof(__fbthrift_field_enum_field) : nullptr; + return enum_field_ref().has_value() ? std::addressof(__fbthrift_field_enum_field) : nullptr; } /** Glean { "field": "enum_field" } */ [[deprecated("Use `FOO.enum_field().value();` instead of `FOO.get_enum_field();`")]] ::apache::thrift::test::MyEnum* get_enum_field() & { - return enum_field_ref() ? std::addressof(__fbthrift_field_enum_field) : nullptr; + return enum_field_ref().has_value() ? std::addressof(__fbthrift_field_enum_field) : nullptr; } /** Glean { "field": "enum_field" } */ [[deprecated("Use `FOO.enum_field().value();` instead of `FOO.get_enum_field();`")]] diff --git a/thrift/compiler/test/fixtures/exceptions/out/cpp2/gen-cpp2/module_types.h b/thrift/compiler/test/fixtures/exceptions/out/cpp2/gen-cpp2/module_types.h index e53bed4dcc1..4c120a0cbd5 100644 --- a/thrift/compiler/test/fixtures/exceptions/out/cpp2/gen-cpp2/module_types.h +++ b/thrift/compiler/test/fixtures/exceptions/out/cpp2/gen-cpp2/module_types.h @@ -422,13 +422,13 @@ class FOLLY_EXPORT Serious : public virtual apache::thrift::TException { /** Glean { "field": "sonnet" } */ [[deprecated("Use `FOO.sonnet().value();` instead of `FOO.get_sonnet();`")]] const ::std::string* get_sonnet() const& { - return sonnet_ref() ? std::addressof(__fbthrift_field_sonnet) : nullptr; + return sonnet_ref().has_value() ? std::addressof(__fbthrift_field_sonnet) : nullptr; } /** Glean { "field": "sonnet" } */ [[deprecated("Use `FOO.sonnet().value();` instead of `FOO.get_sonnet();`")]] ::std::string* get_sonnet() & { - return sonnet_ref() ? std::addressof(__fbthrift_field_sonnet) : nullptr; + return sonnet_ref().has_value() ? std::addressof(__fbthrift_field_sonnet) : nullptr; } /** Glean { "field": "sonnet" } */ [[deprecated("Use `FOO.sonnet().value();` instead of `FOO.get_sonnet();`")]] diff --git a/thrift/compiler/test/fixtures/fatal/out/cpp2/gen-cpp2/module_types.h b/thrift/compiler/test/fixtures/fatal/out/cpp2/gen-cpp2/module_types.h index 42582d31f96..2ca7ee97335 100644 --- a/thrift/compiler/test/fixtures/fatal/out/cpp2/gen-cpp2/module_types.h +++ b/thrift/compiler/test/fixtures/fatal/out/cpp2/gen-cpp2/module_types.h @@ -5855,13 +5855,13 @@ class struct1 final { /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] const ::std::string* get_field1() const& { - return field1_ref() ? std::addressof(__fbthrift_field_field1) : nullptr; + return field1_ref().has_value() ? std::addressof(__fbthrift_field_field1) : nullptr; } /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] ::std::string* get_field1() & { - return field1_ref() ? std::addressof(__fbthrift_field_field1) : nullptr; + return field1_ref().has_value() ? std::addressof(__fbthrift_field_field1) : nullptr; } /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] @@ -8106,13 +8106,13 @@ class struct4 final { /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] const ::std::string* get_field1() const& { - return field1_ref() ? std::addressof(__fbthrift_field_field1) : nullptr; + return field1_ref().has_value() ? std::addressof(__fbthrift_field_field1) : nullptr; } /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] ::std::string* get_field1() & { - return field1_ref() ? std::addressof(__fbthrift_field_field1) : nullptr; + return field1_ref().has_value() ? std::addressof(__fbthrift_field_field1) : nullptr; } /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] @@ -8518,13 +8518,13 @@ class struct5 final { /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] const ::std::string* get_field1() const& { - return field1_ref() ? std::addressof(__fbthrift_field_field1) : nullptr; + return field1_ref().has_value() ? std::addressof(__fbthrift_field_field1) : nullptr; } /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] ::std::string* get_field1() & { - return field1_ref() ? std::addressof(__fbthrift_field_field1) : nullptr; + return field1_ref().has_value() ? std::addressof(__fbthrift_field_field1) : nullptr; } /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] diff --git a/thrift/compiler/test/fixtures/isset_bitpacking/out/cpp2/gen-cpp2/module_types.h b/thrift/compiler/test/fixtures/isset_bitpacking/out/cpp2/gen-cpp2/module_types.h index 6e7605f3324..7a4eff2a07d 100644 --- a/thrift/compiler/test/fixtures/isset_bitpacking/out/cpp2/gen-cpp2/module_types.h +++ b/thrift/compiler/test/fixtures/isset_bitpacking/out/cpp2/gen-cpp2/module_types.h @@ -414,13 +414,13 @@ class Default final { /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] const ::std::int32_t* get_field1() const& { - return field1_ref() ? std::addressof(__fbthrift_field_field1) : nullptr; + return field1_ref().has_value() ? std::addressof(__fbthrift_field_field1) : nullptr; } /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] ::std::int32_t* get_field1() & { - return field1_ref() ? std::addressof(__fbthrift_field_field1) : nullptr; + return field1_ref().has_value() ? std::addressof(__fbthrift_field_field1) : nullptr; } /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] @@ -436,13 +436,13 @@ class Default final { /** Glean { "field": "field2" } */ [[deprecated("Use `FOO.field2().value();` instead of `FOO.get_field2();`")]] const ::std::int32_t* get_field2() const& { - return field2_ref() ? std::addressof(__fbthrift_field_field2) : nullptr; + return field2_ref().has_value() ? std::addressof(__fbthrift_field_field2) : nullptr; } /** Glean { "field": "field2" } */ [[deprecated("Use `FOO.field2().value();` instead of `FOO.get_field2();`")]] ::std::int32_t* get_field2() & { - return field2_ref() ? std::addressof(__fbthrift_field_field2) : nullptr; + return field2_ref().has_value() ? std::addressof(__fbthrift_field_field2) : nullptr; } /** Glean { "field": "field2" } */ [[deprecated("Use `FOO.field2().value();` instead of `FOO.get_field2();`")]] @@ -458,13 +458,13 @@ class Default final { /** Glean { "field": "field3" } */ [[deprecated("Use `FOO.field3().value();` instead of `FOO.get_field3();`")]] const ::std::string* get_field3() const& { - return field3_ref() ? std::addressof(__fbthrift_field_field3) : nullptr; + return field3_ref().has_value() ? std::addressof(__fbthrift_field_field3) : nullptr; } /** Glean { "field": "field3" } */ [[deprecated("Use `FOO.field3().value();` instead of `FOO.get_field3();`")]] ::std::string* get_field3() & { - return field3_ref() ? std::addressof(__fbthrift_field_field3) : nullptr; + return field3_ref().has_value() ? std::addressof(__fbthrift_field_field3) : nullptr; } /** Glean { "field": "field3" } */ [[deprecated("Use `FOO.field3().value();` instead of `FOO.get_field3();`")]] @@ -481,13 +481,13 @@ class Default final { /** Glean { "field": "field4" } */ [[deprecated("Use `FOO.field4().value();` instead of `FOO.get_field4();`")]] const double* get_field4() const& { - return field4_ref() ? std::addressof(__fbthrift_field_field4) : nullptr; + return field4_ref().has_value() ? std::addressof(__fbthrift_field_field4) : nullptr; } /** Glean { "field": "field4" } */ [[deprecated("Use `FOO.field4().value();` instead of `FOO.get_field4();`")]] double* get_field4() & { - return field4_ref() ? std::addressof(__fbthrift_field_field4) : nullptr; + return field4_ref().has_value() ? std::addressof(__fbthrift_field_field4) : nullptr; } /** Glean { "field": "field4" } */ [[deprecated("Use `FOO.field4().value();` instead of `FOO.get_field4();`")]] @@ -814,13 +814,13 @@ class NonAtomic final { /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] const ::std::int32_t* get_field1() const& { - return field1_ref() ? std::addressof(__fbthrift_field_field1) : nullptr; + return field1_ref().has_value() ? std::addressof(__fbthrift_field_field1) : nullptr; } /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] ::std::int32_t* get_field1() & { - return field1_ref() ? std::addressof(__fbthrift_field_field1) : nullptr; + return field1_ref().has_value() ? std::addressof(__fbthrift_field_field1) : nullptr; } /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] @@ -836,13 +836,13 @@ class NonAtomic final { /** Glean { "field": "field2" } */ [[deprecated("Use `FOO.field2().value();` instead of `FOO.get_field2();`")]] const ::std::int32_t* get_field2() const& { - return field2_ref() ? std::addressof(__fbthrift_field_field2) : nullptr; + return field2_ref().has_value() ? std::addressof(__fbthrift_field_field2) : nullptr; } /** Glean { "field": "field2" } */ [[deprecated("Use `FOO.field2().value();` instead of `FOO.get_field2();`")]] ::std::int32_t* get_field2() & { - return field2_ref() ? std::addressof(__fbthrift_field_field2) : nullptr; + return field2_ref().has_value() ? std::addressof(__fbthrift_field_field2) : nullptr; } /** Glean { "field": "field2" } */ [[deprecated("Use `FOO.field2().value();` instead of `FOO.get_field2();`")]] @@ -858,13 +858,13 @@ class NonAtomic final { /** Glean { "field": "field3" } */ [[deprecated("Use `FOO.field3().value();` instead of `FOO.get_field3();`")]] const ::std::string* get_field3() const& { - return field3_ref() ? std::addressof(__fbthrift_field_field3) : nullptr; + return field3_ref().has_value() ? std::addressof(__fbthrift_field_field3) : nullptr; } /** Glean { "field": "field3" } */ [[deprecated("Use `FOO.field3().value();` instead of `FOO.get_field3();`")]] ::std::string* get_field3() & { - return field3_ref() ? std::addressof(__fbthrift_field_field3) : nullptr; + return field3_ref().has_value() ? std::addressof(__fbthrift_field_field3) : nullptr; } /** Glean { "field": "field3" } */ [[deprecated("Use `FOO.field3().value();` instead of `FOO.get_field3();`")]] @@ -881,13 +881,13 @@ class NonAtomic final { /** Glean { "field": "field4" } */ [[deprecated("Use `FOO.field4().value();` instead of `FOO.get_field4();`")]] const double* get_field4() const& { - return field4_ref() ? std::addressof(__fbthrift_field_field4) : nullptr; + return field4_ref().has_value() ? std::addressof(__fbthrift_field_field4) : nullptr; } /** Glean { "field": "field4" } */ [[deprecated("Use `FOO.field4().value();` instead of `FOO.get_field4();`")]] double* get_field4() & { - return field4_ref() ? std::addressof(__fbthrift_field_field4) : nullptr; + return field4_ref().has_value() ? std::addressof(__fbthrift_field_field4) : nullptr; } /** Glean { "field": "field4" } */ [[deprecated("Use `FOO.field4().value();` instead of `FOO.get_field4();`")]] @@ -1214,13 +1214,13 @@ class Atomic final { /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] const ::std::int32_t* get_field1() const& { - return field1_ref() ? std::addressof(__fbthrift_field_field1) : nullptr; + return field1_ref().has_value() ? std::addressof(__fbthrift_field_field1) : nullptr; } /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] ::std::int32_t* get_field1() & { - return field1_ref() ? std::addressof(__fbthrift_field_field1) : nullptr; + return field1_ref().has_value() ? std::addressof(__fbthrift_field_field1) : nullptr; } /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] @@ -1236,13 +1236,13 @@ class Atomic final { /** Glean { "field": "field2" } */ [[deprecated("Use `FOO.field2().value();` instead of `FOO.get_field2();`")]] const ::std::int32_t* get_field2() const& { - return field2_ref() ? std::addressof(__fbthrift_field_field2) : nullptr; + return field2_ref().has_value() ? std::addressof(__fbthrift_field_field2) : nullptr; } /** Glean { "field": "field2" } */ [[deprecated("Use `FOO.field2().value();` instead of `FOO.get_field2();`")]] ::std::int32_t* get_field2() & { - return field2_ref() ? std::addressof(__fbthrift_field_field2) : nullptr; + return field2_ref().has_value() ? std::addressof(__fbthrift_field_field2) : nullptr; } /** Glean { "field": "field2" } */ [[deprecated("Use `FOO.field2().value();` instead of `FOO.get_field2();`")]] @@ -1258,13 +1258,13 @@ class Atomic final { /** Glean { "field": "field3" } */ [[deprecated("Use `FOO.field3().value();` instead of `FOO.get_field3();`")]] const ::std::string* get_field3() const& { - return field3_ref() ? std::addressof(__fbthrift_field_field3) : nullptr; + return field3_ref().has_value() ? std::addressof(__fbthrift_field_field3) : nullptr; } /** Glean { "field": "field3" } */ [[deprecated("Use `FOO.field3().value();` instead of `FOO.get_field3();`")]] ::std::string* get_field3() & { - return field3_ref() ? std::addressof(__fbthrift_field_field3) : nullptr; + return field3_ref().has_value() ? std::addressof(__fbthrift_field_field3) : nullptr; } /** Glean { "field": "field3" } */ [[deprecated("Use `FOO.field3().value();` instead of `FOO.get_field3();`")]] @@ -1281,13 +1281,13 @@ class Atomic final { /** Glean { "field": "field4" } */ [[deprecated("Use `FOO.field4().value();` instead of `FOO.get_field4();`")]] const double* get_field4() const& { - return field4_ref() ? std::addressof(__fbthrift_field_field4) : nullptr; + return field4_ref().has_value() ? std::addressof(__fbthrift_field_field4) : nullptr; } /** Glean { "field": "field4" } */ [[deprecated("Use `FOO.field4().value();` instead of `FOO.get_field4();`")]] double* get_field4() & { - return field4_ref() ? std::addressof(__fbthrift_field_field4) : nullptr; + return field4_ref().has_value() ? std::addressof(__fbthrift_field_field4) : nullptr; } /** Glean { "field": "field4" } */ [[deprecated("Use `FOO.field4().value();` instead of `FOO.get_field4();`")]] @@ -1614,13 +1614,13 @@ class AtomicFoo final { /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] const ::std::int32_t* get_field1() const& { - return field1_ref() ? std::addressof(__fbthrift_field_field1) : nullptr; + return field1_ref().has_value() ? std::addressof(__fbthrift_field_field1) : nullptr; } /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] ::std::int32_t* get_field1() & { - return field1_ref() ? std::addressof(__fbthrift_field_field1) : nullptr; + return field1_ref().has_value() ? std::addressof(__fbthrift_field_field1) : nullptr; } /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] @@ -1636,13 +1636,13 @@ class AtomicFoo final { /** Glean { "field": "field2" } */ [[deprecated("Use `FOO.field2().value();` instead of `FOO.get_field2();`")]] const ::std::int32_t* get_field2() const& { - return field2_ref() ? std::addressof(__fbthrift_field_field2) : nullptr; + return field2_ref().has_value() ? std::addressof(__fbthrift_field_field2) : nullptr; } /** Glean { "field": "field2" } */ [[deprecated("Use `FOO.field2().value();` instead of `FOO.get_field2();`")]] ::std::int32_t* get_field2() & { - return field2_ref() ? std::addressof(__fbthrift_field_field2) : nullptr; + return field2_ref().has_value() ? std::addressof(__fbthrift_field_field2) : nullptr; } /** Glean { "field": "field2" } */ [[deprecated("Use `FOO.field2().value();` instead of `FOO.get_field2();`")]] @@ -1658,13 +1658,13 @@ class AtomicFoo final { /** Glean { "field": "field3" } */ [[deprecated("Use `FOO.field3().value();` instead of `FOO.get_field3();`")]] const ::std::string* get_field3() const& { - return field3_ref() ? std::addressof(__fbthrift_field_field3) : nullptr; + return field3_ref().has_value() ? std::addressof(__fbthrift_field_field3) : nullptr; } /** Glean { "field": "field3" } */ [[deprecated("Use `FOO.field3().value();` instead of `FOO.get_field3();`")]] ::std::string* get_field3() & { - return field3_ref() ? std::addressof(__fbthrift_field_field3) : nullptr; + return field3_ref().has_value() ? std::addressof(__fbthrift_field_field3) : nullptr; } /** Glean { "field": "field3" } */ [[deprecated("Use `FOO.field3().value();` instead of `FOO.get_field3();`")]] @@ -1681,13 +1681,13 @@ class AtomicFoo final { /** Glean { "field": "field4" } */ [[deprecated("Use `FOO.field4().value();` instead of `FOO.get_field4();`")]] const double* get_field4() const& { - return field4_ref() ? std::addressof(__fbthrift_field_field4) : nullptr; + return field4_ref().has_value() ? std::addressof(__fbthrift_field_field4) : nullptr; } /** Glean { "field": "field4" } */ [[deprecated("Use `FOO.field4().value();` instead of `FOO.get_field4();`")]] double* get_field4() & { - return field4_ref() ? std::addressof(__fbthrift_field_field4) : nullptr; + return field4_ref().has_value() ? std::addressof(__fbthrift_field_field4) : nullptr; } /** Glean { "field": "field4" } */ [[deprecated("Use `FOO.field4().value();` instead of `FOO.get_field4();`")]] diff --git a/thrift/compiler/test/fixtures/maps-with-incomplete-types/out/cpp2/gen-cpp2/module_types.h b/thrift/compiler/test/fixtures/maps-with-incomplete-types/out/cpp2/gen-cpp2/module_types.h index 51ca9cf6a08..79e077f3cc8 100644 --- a/thrift/compiler/test/fixtures/maps-with-incomplete-types/out/cpp2/gen-cpp2/module_types.h +++ b/thrift/compiler/test/fixtures/maps-with-incomplete-types/out/cpp2/gen-cpp2/module_types.h @@ -185,13 +185,13 @@ class B final { /** Glean { "field": "field" } */ [[deprecated("Use `FOO.field().value();` instead of `FOO.get_field();`")]] const ::std::int32_t* get_field() const& { - return field_ref() ? std::addressof(__fbthrift_field_field) : nullptr; + return field_ref().has_value() ? std::addressof(__fbthrift_field_field) : nullptr; } /** Glean { "field": "field" } */ [[deprecated("Use `FOO.field().value();` instead of `FOO.get_field();`")]] ::std::int32_t* get_field() & { - return field_ref() ? std::addressof(__fbthrift_field_field) : nullptr; + return field_ref().has_value() ? std::addressof(__fbthrift_field_field) : nullptr; } /** Glean { "field": "field" } */ [[deprecated("Use `FOO.field().value();` instead of `FOO.get_field();`")]] diff --git a/thrift/compiler/test/fixtures/mcpp2-compare/out/cpp2/gen-cpp2/module_types.h b/thrift/compiler/test/fixtures/mcpp2-compare/out/cpp2/gen-cpp2/module_types.h index 0b834048161..a6c5d4416eb 100644 --- a/thrift/compiler/test/fixtures/mcpp2-compare/out/cpp2/gen-cpp2/module_types.h +++ b/thrift/compiler/test/fixtures/mcpp2-compare/out/cpp2/gen-cpp2/module_types.h @@ -2355,13 +2355,13 @@ class MyStruct final { /** Glean { "field": "MyBinaryField2" } */ [[deprecated("Use `FOO.MyBinaryField2().value();` instead of `FOO.get_MyBinaryField2();`")]] const ::std::string* get_MyBinaryField2() const& { - return MyBinaryField2_ref() ? std::addressof(__fbthrift_field_MyBinaryField2) : nullptr; + return MyBinaryField2_ref().has_value() ? std::addressof(__fbthrift_field_MyBinaryField2) : nullptr; } /** Glean { "field": "MyBinaryField2" } */ [[deprecated("Use `FOO.MyBinaryField2().value();` instead of `FOO.get_MyBinaryField2();`")]] ::std::string* get_MyBinaryField2() & { - return MyBinaryField2_ref() ? std::addressof(__fbthrift_field_MyBinaryField2) : nullptr; + return MyBinaryField2_ref().has_value() ? std::addressof(__fbthrift_field_MyBinaryField2) : nullptr; } /** Glean { "field": "MyBinaryField2" } */ [[deprecated("Use `FOO.MyBinaryField2().value();` instead of `FOO.get_MyBinaryField2();`")]] @@ -8029,13 +8029,13 @@ class containerStruct final { /** Glean { "field": "opt_fieldA" } */ [[deprecated("Use `FOO.opt_fieldA().value();` instead of `FOO.get_opt_fieldA();`")]] const bool* get_opt_fieldA() const& { - return opt_fieldA_ref() ? std::addressof(opt_fieldA) : nullptr; + return opt_fieldA_ref().has_value() ? std::addressof(opt_fieldA) : nullptr; } /** Glean { "field": "opt_fieldA" } */ [[deprecated("Use `FOO.opt_fieldA().value();` instead of `FOO.get_opt_fieldA();`")]] bool* get_opt_fieldA() & { - return opt_fieldA_ref() ? std::addressof(opt_fieldA) : nullptr; + return opt_fieldA_ref().has_value() ? std::addressof(opt_fieldA) : nullptr; } /** Glean { "field": "opt_fieldA" } */ [[deprecated("Use `FOO.opt_fieldA().value();` instead of `FOO.get_opt_fieldA();`")]] @@ -8201,13 +8201,13 @@ class containerStruct final { /** Glean { "field": "opt_fieldE" } */ [[deprecated("Use `FOO.opt_fieldE().value();` instead of `FOO.get_opt_fieldE();`")]] const ::std::string* get_opt_fieldE() const& { - return opt_fieldE_ref() ? std::addressof(opt_fieldE) : nullptr; + return opt_fieldE_ref().has_value() ? std::addressof(opt_fieldE) : nullptr; } /** Glean { "field": "opt_fieldE" } */ [[deprecated("Use `FOO.opt_fieldE().value();` instead of `FOO.get_opt_fieldE();`")]] ::std::string* get_opt_fieldE() & { - return opt_fieldE_ref() ? std::addressof(opt_fieldE) : nullptr; + return opt_fieldE_ref().has_value() ? std::addressof(opt_fieldE) : nullptr; } /** Glean { "field": "opt_fieldE" } */ [[deprecated("Use `FOO.opt_fieldE().value();` instead of `FOO.get_opt_fieldE();`")]] @@ -8415,13 +8415,13 @@ class containerStruct final { /** Glean { "field": "opt_fieldR" } */ [[deprecated("Use `FOO.opt_fieldR().value();` instead of `FOO.get_opt_fieldR();`")]] const ::some::valid::ns::MyEnumA* get_opt_fieldR() const& { - return opt_fieldR_ref() ? std::addressof(opt_fieldR) : nullptr; + return opt_fieldR_ref().has_value() ? std::addressof(opt_fieldR) : nullptr; } /** Glean { "field": "opt_fieldR" } */ [[deprecated("Use `FOO.opt_fieldR().value();` instead of `FOO.get_opt_fieldR();`")]] ::some::valid::ns::MyEnumA* get_opt_fieldR() & { - return opt_fieldR_ref() ? std::addressof(opt_fieldR) : nullptr; + return opt_fieldR_ref().has_value() ? std::addressof(opt_fieldR) : nullptr; } /** Glean { "field": "opt_fieldR" } */ [[deprecated("Use `FOO.opt_fieldR().value();` instead of `FOO.get_opt_fieldR();`")]] diff --git a/thrift/compiler/test/fixtures/mcpp2-compare/out/cpp2_extra_services/gen-cpp2/extra_services_types.h b/thrift/compiler/test/fixtures/mcpp2-compare/out/cpp2_extra_services/gen-cpp2/extra_services_types.h index 960941ed0ba..2b86a50884f 100644 --- a/thrift/compiler/test/fixtures/mcpp2-compare/out/cpp2_extra_services/gen-cpp2/extra_services_types.h +++ b/thrift/compiler/test/fixtures/mcpp2-compare/out/cpp2_extra_services/gen-cpp2/extra_services_types.h @@ -891,13 +891,13 @@ class containerStruct2 final { /** Glean { "field": "opt_fieldA" } */ [[deprecated("Use `FOO.opt_fieldA().value();` instead of `FOO.get_opt_fieldA();`")]] const bool* get_opt_fieldA() const& { - return opt_fieldA_ref() ? std::addressof(__fbthrift_field_opt_fieldA) : nullptr; + return opt_fieldA_ref().has_value() ? std::addressof(__fbthrift_field_opt_fieldA) : nullptr; } /** Glean { "field": "opt_fieldA" } */ [[deprecated("Use `FOO.opt_fieldA().value();` instead of `FOO.get_opt_fieldA();`")]] bool* get_opt_fieldA() & { - return opt_fieldA_ref() ? std::addressof(__fbthrift_field_opt_fieldA) : nullptr; + return opt_fieldA_ref().has_value() ? std::addressof(__fbthrift_field_opt_fieldA) : nullptr; } /** Glean { "field": "opt_fieldA" } */ [[deprecated("Use `FOO.opt_fieldA().value();` instead of `FOO.get_opt_fieldA();`")]] @@ -1063,13 +1063,13 @@ class containerStruct2 final { /** Glean { "field": "opt_fieldE" } */ [[deprecated("Use `FOO.opt_fieldE().value();` instead of `FOO.get_opt_fieldE();`")]] const ::std::string* get_opt_fieldE() const& { - return opt_fieldE_ref() ? std::addressof(__fbthrift_field_opt_fieldE) : nullptr; + return opt_fieldE_ref().has_value() ? std::addressof(__fbthrift_field_opt_fieldE) : nullptr; } /** Glean { "field": "opt_fieldE" } */ [[deprecated("Use `FOO.opt_fieldE().value();` instead of `FOO.get_opt_fieldE();`")]] ::std::string* get_opt_fieldE() & { - return opt_fieldE_ref() ? std::addressof(__fbthrift_field_opt_fieldE) : nullptr; + return opt_fieldE_ref().has_value() ? std::addressof(__fbthrift_field_opt_fieldE) : nullptr; } /** Glean { "field": "opt_fieldE" } */ [[deprecated("Use `FOO.opt_fieldE().value();` instead of `FOO.get_opt_fieldE();`")]] diff --git a/thrift/compiler/test/fixtures/mixin/out/cpp2/gen-cpp2/module_types.h b/thrift/compiler/test/fixtures/mixin/out/cpp2/gen-cpp2/module_types.h index 46ab81aada5..7c924237d5a 100644 --- a/thrift/compiler/test/fixtures/mixin/out/cpp2/gen-cpp2/module_types.h +++ b/thrift/compiler/test/fixtures/mixin/out/cpp2/gen-cpp2/module_types.h @@ -464,13 +464,13 @@ class Mixin2 final { /** Glean { "field": "field2" } */ [[deprecated("Use `FOO.field2().value();` instead of `FOO.get_field2();`")]] const ::std::string* get_field2() const& { - return field2_ref() ? std::addressof(__fbthrift_field_field2) : nullptr; + return field2_ref().has_value() ? std::addressof(__fbthrift_field_field2) : nullptr; } /** Glean { "field": "field2" } */ [[deprecated("Use `FOO.field2().value();` instead of `FOO.get_field2();`")]] ::std::string* get_field2() & { - return field2_ref() ? std::addressof(__fbthrift_field_field2) : nullptr; + return field2_ref().has_value() ? std::addressof(__fbthrift_field_field2) : nullptr; } /** Glean { "field": "field2" } */ [[deprecated("Use `FOO.field2().value();` instead of `FOO.get_field2();`")]] diff --git a/thrift/compiler/test/fixtures/nimble/out/cpp2/gen-cpp2/module_types.h b/thrift/compiler/test/fixtures/nimble/out/cpp2/gen-cpp2/module_types.h index 64e2af8fb1f..78e5f9d3baa 100644 --- a/thrift/compiler/test/fixtures/nimble/out/cpp2/gen-cpp2/module_types.h +++ b/thrift/compiler/test/fixtures/nimble/out/cpp2/gen-cpp2/module_types.h @@ -366,13 +366,13 @@ class BasicTypes final { /** Glean { "field": "second" } */ [[deprecated("Use `FOO.second().value();` instead of `FOO.get_second();`")]] const ::std::int32_t* get_second() const& { - return second_ref() ? std::addressof(__fbthrift_field_second) : nullptr; + return second_ref().has_value() ? std::addressof(__fbthrift_field_second) : nullptr; } /** Glean { "field": "second" } */ [[deprecated("Use `FOO.second().value();` instead of `FOO.get_second();`")]] ::std::int32_t* get_second() & { - return second_ref() ? std::addressof(__fbthrift_field_second) : nullptr; + return second_ref().has_value() ? std::addressof(__fbthrift_field_second) : nullptr; } /** Glean { "field": "second" } */ [[deprecated("Use `FOO.second().value();` instead of `FOO.get_second();`")]] @@ -388,13 +388,13 @@ class BasicTypes final { /** Glean { "field": "third" } */ [[deprecated("Use `FOO.third().value();` instead of `FOO.get_third();`")]] const ::std::int64_t* get_third() const& { - return third_ref() ? std::addressof(__fbthrift_field_third) : nullptr; + return third_ref().has_value() ? std::addressof(__fbthrift_field_third) : nullptr; } /** Glean { "field": "third" } */ [[deprecated("Use `FOO.third().value();` instead of `FOO.get_third();`")]] ::std::int64_t* get_third() & { - return third_ref() ? std::addressof(__fbthrift_field_third) : nullptr; + return third_ref().has_value() ? std::addressof(__fbthrift_field_third) : nullptr; } /** Glean { "field": "third" } */ [[deprecated("Use `FOO.third().value();` instead of `FOO.get_third();`")]] diff --git a/thrift/compiler/test/fixtures/optionals/out/cpp2/gen-cpp2/module_types.h b/thrift/compiler/test/fixtures/optionals/out/cpp2/gen-cpp2/module_types.h index 0da66986c57..72d9e225d52 100644 --- a/thrift/compiler/test/fixtures/optionals/out/cpp2/gen-cpp2/module_types.h +++ b/thrift/compiler/test/fixtures/optionals/out/cpp2/gen-cpp2/module_types.h @@ -917,13 +917,13 @@ class Vehicle final { /** Glean { "field": "licensePlate" } */ [[deprecated("Use `FOO.licensePlate().value();` instead of `FOO.get_licensePlate();`")]] const ::std::string* get_licensePlate() const& { - return licensePlate_ref() ? std::addressof(__fbthrift_field_licensePlate) : nullptr; + return licensePlate_ref().has_value() ? std::addressof(__fbthrift_field_licensePlate) : nullptr; } /** Glean { "field": "licensePlate" } */ [[deprecated("Use `FOO.licensePlate().value();` instead of `FOO.get_licensePlate();`")]] ::std::string* get_licensePlate() & { - return licensePlate_ref() ? std::addressof(__fbthrift_field_licensePlate) : nullptr; + return licensePlate_ref().has_value() ? std::addressof(__fbthrift_field_licensePlate) : nullptr; } /** Glean { "field": "licensePlate" } */ [[deprecated("Use `FOO.licensePlate().value();` instead of `FOO.get_licensePlate();`")]] @@ -940,13 +940,13 @@ class Vehicle final { /** Glean { "field": "description" } */ [[deprecated("Use `FOO.description().value();` instead of `FOO.get_description();`")]] const ::std::string* get_description() const& { - return description_ref() ? std::addressof(__fbthrift_field_description) : nullptr; + return description_ref().has_value() ? std::addressof(__fbthrift_field_description) : nullptr; } /** Glean { "field": "description" } */ [[deprecated("Use `FOO.description().value();` instead of `FOO.get_description();`")]] ::std::string* get_description() & { - return description_ref() ? std::addressof(__fbthrift_field_description) : nullptr; + return description_ref().has_value() ? std::addressof(__fbthrift_field_description) : nullptr; } /** Glean { "field": "description" } */ [[deprecated("Use `FOO.description().value();` instead of `FOO.get_description();`")]] @@ -963,13 +963,13 @@ class Vehicle final { /** Glean { "field": "name" } */ [[deprecated("Use `FOO.name().value();` instead of `FOO.get_name();`")]] const ::std::string* get_name() const& { - return name_ref() ? std::addressof(__fbthrift_field_name) : nullptr; + return name_ref().has_value() ? std::addressof(__fbthrift_field_name) : nullptr; } /** Glean { "field": "name" } */ [[deprecated("Use `FOO.name().value();` instead of `FOO.get_name();`")]] ::std::string* get_name() & { - return name_ref() ? std::addressof(__fbthrift_field_name) : nullptr; + return name_ref().has_value() ? std::addressof(__fbthrift_field_name) : nullptr; } /** Glean { "field": "name" } */ [[deprecated("Use `FOO.name().value();` instead of `FOO.get_name();`")]] @@ -986,13 +986,13 @@ class Vehicle final { /** Glean { "field": "hasAC" } */ [[deprecated("Use `FOO.hasAC().value();` instead of `FOO.get_hasAC();`")]] const bool* get_hasAC() const& { - return hasAC_ref() ? std::addressof(__fbthrift_field_hasAC) : nullptr; + return hasAC_ref().has_value() ? std::addressof(__fbthrift_field_hasAC) : nullptr; } /** Glean { "field": "hasAC" } */ [[deprecated("Use `FOO.hasAC().value();` instead of `FOO.get_hasAC();`")]] bool* get_hasAC() & { - return hasAC_ref() ? std::addressof(__fbthrift_field_hasAC) : nullptr; + return hasAC_ref().has_value() ? std::addressof(__fbthrift_field_hasAC) : nullptr; } /** Glean { "field": "hasAC" } */ [[deprecated("Use `FOO.hasAC().value();` instead of `FOO.get_hasAC();`")]] @@ -1664,13 +1664,13 @@ class Person final { /** Glean { "field": "age" } */ [[deprecated("Use `FOO.age().value();` instead of `FOO.get_age();`")]] const ::std::int16_t* get_age() const& { - return age_ref() ? std::addressof(__fbthrift_field_age) : nullptr; + return age_ref().has_value() ? std::addressof(__fbthrift_field_age) : nullptr; } /** Glean { "field": "age" } */ [[deprecated("Use `FOO.age().value();` instead of `FOO.get_age();`")]] ::std::int16_t* get_age() & { - return age_ref() ? std::addressof(__fbthrift_field_age) : nullptr; + return age_ref().has_value() ? std::addressof(__fbthrift_field_age) : nullptr; } /** Glean { "field": "age" } */ [[deprecated("Use `FOO.age().value();` instead of `FOO.get_age();`")]] @@ -1686,13 +1686,13 @@ class Person final { /** Glean { "field": "address" } */ [[deprecated("Use `FOO.address().value();` instead of `FOO.get_address();`")]] const ::std::string* get_address() const& { - return address_ref() ? std::addressof(__fbthrift_field_address) : nullptr; + return address_ref().has_value() ? std::addressof(__fbthrift_field_address) : nullptr; } /** Glean { "field": "address" } */ [[deprecated("Use `FOO.address().value();` instead of `FOO.get_address();`")]] ::std::string* get_address() & { - return address_ref() ? std::addressof(__fbthrift_field_address) : nullptr; + return address_ref().has_value() ? std::addressof(__fbthrift_field_address) : nullptr; } /** Glean { "field": "address" } */ [[deprecated("Use `FOO.address().value();` instead of `FOO.get_address();`")]] @@ -1743,13 +1743,13 @@ class Person final { /** Glean { "field": "bestFriend" } */ [[deprecated("Use `FOO.bestFriend().value();` instead of `FOO.get_bestFriend();`")]] const ::cpp2::PersonID* get_bestFriend() const& { - return bestFriend_ref() ? std::addressof(__fbthrift_field_bestFriend) : nullptr; + return bestFriend_ref().has_value() ? std::addressof(__fbthrift_field_bestFriend) : nullptr; } /** Glean { "field": "bestFriend" } */ [[deprecated("Use `FOO.bestFriend().value();` instead of `FOO.get_bestFriend();`")]] ::cpp2::PersonID* get_bestFriend() & { - return bestFriend_ref() ? std::addressof(__fbthrift_field_bestFriend) : nullptr; + return bestFriend_ref().has_value() ? std::addressof(__fbthrift_field_bestFriend) : nullptr; } /** Glean { "field": "bestFriend" } */ [[deprecated("Use `FOO.bestFriend().value();` instead of `FOO.get_bestFriend();`")]] @@ -1782,13 +1782,13 @@ class Person final { /** Glean { "field": "afraidOfAnimal" } */ [[deprecated("Use `FOO.afraidOfAnimal().value();` instead of `FOO.get_afraidOfAnimal();`")]] const ::cpp2::Animal* get_afraidOfAnimal() const& { - return afraidOfAnimal_ref() ? std::addressof(__fbthrift_field_afraidOfAnimal) : nullptr; + return afraidOfAnimal_ref().has_value() ? std::addressof(__fbthrift_field_afraidOfAnimal) : nullptr; } /** Glean { "field": "afraidOfAnimal" } */ [[deprecated("Use `FOO.afraidOfAnimal().value();` instead of `FOO.get_afraidOfAnimal();`")]] ::cpp2::Animal* get_afraidOfAnimal() & { - return afraidOfAnimal_ref() ? std::addressof(__fbthrift_field_afraidOfAnimal) : nullptr; + return afraidOfAnimal_ref().has_value() ? std::addressof(__fbthrift_field_afraidOfAnimal) : nullptr; } /** Glean { "field": "afraidOfAnimal" } */ [[deprecated("Use `FOO.afraidOfAnimal().value();` instead of `FOO.get_afraidOfAnimal();`")]] diff --git a/thrift/compiler/test/fixtures/py3/out/cpp2/gen-py3cpp/module_types.h b/thrift/compiler/test/fixtures/py3/out/cpp2/gen-py3cpp/module_types.h index e0ef9757b60..f6015b039b0 100644 --- a/thrift/compiler/test/fixtures/py3/out/cpp2/gen-py3cpp/module_types.h +++ b/thrift/compiler/test/fixtures/py3/out/cpp2/gen-py3cpp/module_types.h @@ -1727,13 +1727,13 @@ class OptionalRefStruct final { /** Glean { "field": "optional_blob" } */ [[deprecated("Use `FOO.optional_blob().value();` instead of `FOO.get_optional_blob();`")]] const ::py3::simple::IOBufPtr* get_optional_blob() const& { - return optional_blob_ref() ? std::addressof(__fbthrift_field_optional_blob) : nullptr; + return optional_blob_ref().has_value() ? std::addressof(__fbthrift_field_optional_blob) : nullptr; } /** Glean { "field": "optional_blob" } */ [[deprecated("Use `FOO.optional_blob().value();` instead of `FOO.get_optional_blob();`")]] ::py3::simple::IOBufPtr* get_optional_blob() & { - return optional_blob_ref() ? std::addressof(__fbthrift_field_optional_blob) : nullptr; + return optional_blob_ref().has_value() ? std::addressof(__fbthrift_field_optional_blob) : nullptr; } /** Glean { "field": "optional_blob" } */ [[deprecated("Use `FOO.optional_blob().value();` instead of `FOO.get_optional_blob();`")]] diff --git a/thrift/compiler/test/fixtures/python_capi/out/cpp2/gen-cpp2/module_types.h b/thrift/compiler/test/fixtures/python_capi/out/cpp2/gen-cpp2/module_types.h index 9f627a3e3d4..cbacd829b7a 100644 --- a/thrift/compiler/test/fixtures/python_capi/out/cpp2/gen-cpp2/module_types.h +++ b/thrift/compiler/test/fixtures/python_capi/out/cpp2/gen-cpp2/module_types.h @@ -3030,13 +3030,13 @@ class PrimitiveStruct final { /** Glean { "field": "floaty" } */ [[deprecated("Use `FOO.floaty().value();` instead of `FOO.get_floaty();`")]] const float* get_floaty() const& { - return floaty_ref() ? std::addressof(__fbthrift_field_floaty) : nullptr; + return floaty_ref().has_value() ? std::addressof(__fbthrift_field_floaty) : nullptr; } /** Glean { "field": "floaty" } */ [[deprecated("Use `FOO.floaty().value();` instead of `FOO.get_floaty();`")]] float* get_floaty() & { - return floaty_ref() ? std::addressof(__fbthrift_field_floaty) : nullptr; + return floaty_ref().has_value() ? std::addressof(__fbthrift_field_floaty) : nullptr; } /** Glean { "field": "floaty" } */ [[deprecated("Use `FOO.floaty().value();` instead of `FOO.get_floaty();`")]] diff --git a/thrift/compiler/test/fixtures/python_capi/out/cpp2_serialized_dep/gen-cpp2/serialized_dep_types.h b/thrift/compiler/test/fixtures/python_capi/out/cpp2_serialized_dep/gen-cpp2/serialized_dep_types.h index 07aef3df251..a5b5c4736b7 100644 --- a/thrift/compiler/test/fixtures/python_capi/out/cpp2_serialized_dep/gen-cpp2/serialized_dep_types.h +++ b/thrift/compiler/test/fixtures/python_capi/out/cpp2_serialized_dep/gen-cpp2/serialized_dep_types.h @@ -460,13 +460,13 @@ class SerializedStruct final { /** Glean { "field": "os" } */ [[deprecated("Use `FOO.os().value();` instead of `FOO.get_os();`")]] const ::std::string* get_os() const& { - return os_ref() ? std::addressof(__fbthrift_field_os) : nullptr; + return os_ref().has_value() ? std::addressof(__fbthrift_field_os) : nullptr; } /** Glean { "field": "os" } */ [[deprecated("Use `FOO.os().value();` instead of `FOO.get_os();`")]] ::std::string* get_os() & { - return os_ref() ? std::addressof(__fbthrift_field_os) : nullptr; + return os_ref().has_value() ? std::addressof(__fbthrift_field_os) : nullptr; } /** Glean { "field": "os" } */ [[deprecated("Use `FOO.os().value();` instead of `FOO.get_os();`")]] @@ -1083,13 +1083,13 @@ class FOLLY_EXPORT SerializedError : public virtual apache::thrift::TException { /** Glean { "field": "os" } */ [[deprecated("Use `FOO.os().value();` instead of `FOO.get_os();`")]] const ::std::string* get_os() const& { - return os_ref() ? std::addressof(__fbthrift_field_os) : nullptr; + return os_ref().has_value() ? std::addressof(__fbthrift_field_os) : nullptr; } /** Glean { "field": "os" } */ [[deprecated("Use `FOO.os().value();` instead of `FOO.get_os();`")]] ::std::string* get_os() & { - return os_ref() ? std::addressof(__fbthrift_field_os) : nullptr; + return os_ref().has_value() ? std::addressof(__fbthrift_field_os) : nullptr; } /** Glean { "field": "os" } */ [[deprecated("Use `FOO.os().value();` instead of `FOO.get_os();`")]] @@ -1475,13 +1475,13 @@ class MarshalStruct final { /** Glean { "field": "os" } */ [[deprecated("Use `FOO.os().value();` instead of `FOO.get_os();`")]] const ::std::string* get_os() const& { - return os_ref() ? std::addressof(__fbthrift_field_os) : nullptr; + return os_ref().has_value() ? std::addressof(__fbthrift_field_os) : nullptr; } /** Glean { "field": "os" } */ [[deprecated("Use `FOO.os().value();` instead of `FOO.get_os();`")]] ::std::string* get_os() & { - return os_ref() ? std::addressof(__fbthrift_field_os) : nullptr; + return os_ref().has_value() ? std::addressof(__fbthrift_field_os) : nullptr; } /** Glean { "field": "os" } */ [[deprecated("Use `FOO.os().value();` instead of `FOO.get_os();`")]] @@ -2098,13 +2098,13 @@ class FOLLY_EXPORT MarshalError : public virtual apache::thrift::TException { /** Glean { "field": "os" } */ [[deprecated("Use `FOO.os().value();` instead of `FOO.get_os();`")]] const ::std::string* get_os() const& { - return os_ref() ? std::addressof(__fbthrift_field_os) : nullptr; + return os_ref().has_value() ? std::addressof(__fbthrift_field_os) : nullptr; } /** Glean { "field": "os" } */ [[deprecated("Use `FOO.os().value();` instead of `FOO.get_os();`")]] ::std::string* get_os() & { - return os_ref() ? std::addressof(__fbthrift_field_os) : nullptr; + return os_ref().has_value() ? std::addressof(__fbthrift_field_os) : nullptr; } /** Glean { "field": "os" } */ [[deprecated("Use `FOO.os().value();` instead of `FOO.get_os();`")]] diff --git a/thrift/compiler/test/fixtures/single_file_service/out/cpp2/gen-cpp2/module_types.h b/thrift/compiler/test/fixtures/single_file_service/out/cpp2/gen-cpp2/module_types.h index f13213ab3a9..e494b854527 100644 --- a/thrift/compiler/test/fixtures/single_file_service/out/cpp2/gen-cpp2/module_types.h +++ b/thrift/compiler/test/fixtures/single_file_service/out/cpp2/gen-cpp2/module_types.h @@ -180,13 +180,13 @@ class Foo final { /** Glean { "field": "value" } */ [[deprecated("Use `FOO.value().value();` instead of `FOO.get_value();`")]] const ::std::int32_t* get_value() const& { - return value_ref() ? std::addressof(__fbthrift_field_value) : nullptr; + return value_ref().has_value() ? std::addressof(__fbthrift_field_value) : nullptr; } /** Glean { "field": "value" } */ [[deprecated("Use `FOO.value().value();` instead of `FOO.get_value();`")]] ::std::int32_t* get_value() & { - return value_ref() ? std::addressof(__fbthrift_field_value) : nullptr; + return value_ref().has_value() ? std::addressof(__fbthrift_field_value) : nullptr; } /** Glean { "field": "value" } */ [[deprecated("Use `FOO.value().value();` instead of `FOO.get_value();`")]] diff --git a/thrift/compiler/test/fixtures/single_file_service/out/cpp2_module_structs/gen-cpp2/module_structs_types.h b/thrift/compiler/test/fixtures/single_file_service/out/cpp2_module_structs/gen-cpp2/module_structs_types.h index af05310ba0c..ece0f0bc7db 100644 --- a/thrift/compiler/test/fixtures/single_file_service/out/cpp2_module_structs/gen-cpp2/module_structs_types.h +++ b/thrift/compiler/test/fixtures/single_file_service/out/cpp2_module_structs/gen-cpp2/module_structs_types.h @@ -179,13 +179,13 @@ class Foo final { /** Glean { "field": "value" } */ [[deprecated("Use `FOO.value().value();` instead of `FOO.get_value();`")]] const ::std::int32_t* get_value() const& { - return value_ref() ? std::addressof(__fbthrift_field_value) : nullptr; + return value_ref().has_value() ? std::addressof(__fbthrift_field_value) : nullptr; } /** Glean { "field": "value" } */ [[deprecated("Use `FOO.value().value();` instead of `FOO.get_value();`")]] ::std::int32_t* get_value() & { - return value_ref() ? std::addressof(__fbthrift_field_value) : nullptr; + return value_ref().has_value() ? std::addressof(__fbthrift_field_value) : nullptr; } /** Glean { "field": "value" } */ [[deprecated("Use `FOO.value().value();` instead of `FOO.get_value();`")]] diff --git a/thrift/compiler/test/fixtures/tablebased/out/cpp2/gen-cpp2/module_types.h b/thrift/compiler/test/fixtures/tablebased/out/cpp2/gen-cpp2/module_types.h index 92083e59975..73612be7c57 100644 --- a/thrift/compiler/test/fixtures/tablebased/out/cpp2/gen-cpp2/module_types.h +++ b/thrift/compiler/test/fixtures/tablebased/out/cpp2/gen-cpp2/module_types.h @@ -516,13 +516,13 @@ class TrivialTypesStruct final { /** Glean { "field": "fieldA" } */ [[deprecated("Use `FOO.fieldA().value();` instead of `FOO.get_fieldA();`")]] const ::std::int32_t* get_fieldA() const& { - return fieldA_ref() ? std::addressof(__fbthrift_field_fieldA) : nullptr; + return fieldA_ref().has_value() ? std::addressof(__fbthrift_field_fieldA) : nullptr; } /** Glean { "field": "fieldA" } */ [[deprecated("Use `FOO.fieldA().value();` instead of `FOO.get_fieldA();`")]] ::std::int32_t* get_fieldA() & { - return fieldA_ref() ? std::addressof(__fbthrift_field_fieldA) : nullptr; + return fieldA_ref().has_value() ? std::addressof(__fbthrift_field_fieldA) : nullptr; } /** Glean { "field": "fieldA" } */ [[deprecated("Use `FOO.fieldA().value();` instead of `FOO.get_fieldA();`")]] @@ -538,13 +538,13 @@ class TrivialTypesStruct final { /** Glean { "field": "fieldB" } */ [[deprecated("Use `FOO.fieldB().value();` instead of `FOO.get_fieldB();`")]] const ::std::string* get_fieldB() const& { - return fieldB_ref() ? std::addressof(__fbthrift_field_fieldB) : nullptr; + return fieldB_ref().has_value() ? std::addressof(__fbthrift_field_fieldB) : nullptr; } /** Glean { "field": "fieldB" } */ [[deprecated("Use `FOO.fieldB().value();` instead of `FOO.get_fieldB();`")]] ::std::string* get_fieldB() & { - return fieldB_ref() ? std::addressof(__fbthrift_field_fieldB) : nullptr; + return fieldB_ref().has_value() ? std::addressof(__fbthrift_field_fieldB) : nullptr; } /** Glean { "field": "fieldB" } */ [[deprecated("Use `FOO.fieldB().value();` instead of `FOO.get_fieldB();`")]] @@ -561,13 +561,13 @@ class TrivialTypesStruct final { /** Glean { "field": "fieldC" } */ [[deprecated("Use `FOO.fieldC().value();` instead of `FOO.get_fieldC();`")]] const ::std::string* get_fieldC() const& { - return fieldC_ref() ? std::addressof(__fbthrift_field_fieldC) : nullptr; + return fieldC_ref().has_value() ? std::addressof(__fbthrift_field_fieldC) : nullptr; } /** Glean { "field": "fieldC" } */ [[deprecated("Use `FOO.fieldC().value();` instead of `FOO.get_fieldC();`")]] ::std::string* get_fieldC() & { - return fieldC_ref() ? std::addressof(__fbthrift_field_fieldC) : nullptr; + return fieldC_ref().has_value() ? std::addressof(__fbthrift_field_fieldC) : nullptr; } /** Glean { "field": "fieldC" } */ [[deprecated("Use `FOO.fieldC().value();` instead of `FOO.get_fieldC();`")]] @@ -584,13 +584,13 @@ class TrivialTypesStruct final { /** Glean { "field": "fieldD" } */ [[deprecated("Use `FOO.fieldD().value();` instead of `FOO.get_fieldD();`")]] const ::test::fixtures::tablebased::IOBufPtr* get_fieldD() const& { - return fieldD_ref() ? std::addressof(__fbthrift_field_fieldD) : nullptr; + return fieldD_ref().has_value() ? std::addressof(__fbthrift_field_fieldD) : nullptr; } /** Glean { "field": "fieldD" } */ [[deprecated("Use `FOO.fieldD().value();` instead of `FOO.get_fieldD();`")]] ::test::fixtures::tablebased::IOBufPtr* get_fieldD() & { - return fieldD_ref() ? std::addressof(__fbthrift_field_fieldD) : nullptr; + return fieldD_ref().has_value() ? std::addressof(__fbthrift_field_fieldD) : nullptr; } /** Glean { "field": "fieldD" } */ [[deprecated("Use `FOO.fieldD().value();` instead of `FOO.get_fieldD();`")]] diff --git a/thrift/compiler/test/fixtures/visitation/out/cpp2/gen-cpp2/module_types.h b/thrift/compiler/test/fixtures/visitation/out/cpp2/gen-cpp2/module_types.h index fe2da2b7319..3ce687ee0c9 100644 --- a/thrift/compiler/test/fixtures/visitation/out/cpp2/gen-cpp2/module_types.h +++ b/thrift/compiler/test/fixtures/visitation/out/cpp2/gen-cpp2/module_types.h @@ -5841,13 +5841,13 @@ class struct1 final { /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] const ::std::string* get_field1() const& { - return field1_ref() ? std::addressof(__fbthrift_field_field1) : nullptr; + return field1_ref().has_value() ? std::addressof(__fbthrift_field_field1) : nullptr; } /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] ::std::string* get_field1() & { - return field1_ref() ? std::addressof(__fbthrift_field_field1) : nullptr; + return field1_ref().has_value() ? std::addressof(__fbthrift_field_field1) : nullptr; } /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] @@ -8105,13 +8105,13 @@ class struct4 final { /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] const ::std::string* get_field1() const& { - return field1_ref() ? std::addressof(__fbthrift_field_field1) : nullptr; + return field1_ref().has_value() ? std::addressof(__fbthrift_field_field1) : nullptr; } /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] ::std::string* get_field1() & { - return field1_ref() ? std::addressof(__fbthrift_field_field1) : nullptr; + return field1_ref().has_value() ? std::addressof(__fbthrift_field_field1) : nullptr; } /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] @@ -8517,13 +8517,13 @@ class struct5 final { /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] const ::std::string* get_field1() const& { - return field1_ref() ? std::addressof(__fbthrift_field_field1) : nullptr; + return field1_ref().has_value() ? std::addressof(__fbthrift_field_field1) : nullptr; } /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]] ::std::string* get_field1() & { - return field1_ref() ? std::addressof(__fbthrift_field_field1) : nullptr; + return field1_ref().has_value() ? std::addressof(__fbthrift_field_field1) : nullptr; } /** Glean { "field": "field1" } */ [[deprecated("Use `FOO.field1().value();` instead of `FOO.get_field1();`")]]