-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
C++: Fix code generation for union field types that are constructed with allocators #325
Conversation
…ith allocators - Added initialization constructor to std::variant instance used by union composite types in c++17 and above - Added initialization logic in allocator constructors for union_value member of union composite types
…g constructor support for all c++ versions
VariantType(nunavut::support::in_place_index_t<I> i, Args&&... args) : | ||
Base{std::in_place_index_t<I>{}, std::forward<Args>(args)...} | ||
{ | ||
(void)i; // avoid unused param warning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can just omit i
in the constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. Just need to add tests.
|
rhs: str = "" | ||
leading_args: typing.List[str] = [] | ||
trailing_args: typing.List[str] = [] | ||
if needs_variant_init_args(composite_subtype): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
false branch not covered in python test
if language.get_option("ctor_convention") == ConstructorConvention.UsesLeadingAllocator.value: | ||
leading_args.extend(["std::allocator_arg", "allocator"]) | ||
else: | ||
trailing_args.append("allocator") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not covered in python test
|
||
if needs_vla_init_args(instance, special_method): | ||
constructor_args = language.get_option("variable_array_type_constructor_args") | ||
if isinstance(constructor_args, str) and len(constructor_args) > 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
false branch not covered in python test.
|
||
return value_initializer | ||
@template_language_test(__name__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this filter not coverend in python tests.
} | ||
|
||
/** | ||
* Verify that the variant value can be fetched only at the alternative index for the type being held |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a test that actually passes an allocator through to a variant type constructor.
Closing as abandoned. |
in_place_index_t
to nunavut support library; adds the resource in c++14, referencesstd::in_place_index_t
in c++17 buildsnunavut::support::in_place_index_t
that specifies the alternative type to holdunion_value
member of union composite types is now generated, with appropriate parameters, in copy and move constructors with allocatorsVariantType
internal logic withIndexOf
property