Skip to content
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

Specify copy assignment operator for vec swizzles #678

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gmlueck
Copy link
Contributor

@gmlueck gmlueck commented Dec 6, 2024

Even though we specify an assignment operator for
__writeable_swizzle__ like this:

template</*unspecified*/>
const __writeable_swizzle__&
operator=(const __writeable_swizzle__</*unspecified*/>& rhs) const

The compiler will not select this operator when the left-hand-side has the same type as the right-hand-side. (Even though the template constraints would allow such a selection.) Instead, the compiler will generate the default copy assignment operator and call that.

Since the default copy assignment operator would not be correct (performing a shallow copy), the __writeable_swizzle__ class must provide a user defined copy assignment operator.

The copy assignment operator for __const_swizzle__ was already deleted in the "constructors" section. It seemed better to move this to the "member functions" part of the specification, next to the specification for the copy assignment operator for __writeable_swizzle__.

Even though we specify an assignment operator for
`__writeable_swizzle__` like this:

```
template</*unspecified*/>
const __writeable_swizzle__&
operator=(const __writeable_swizzle__</*unspecified*/>& rhs) const
```

The compiler will not select this operator when the left-hand-side
has the same type as the right-hand-side.  (Even though the template
constraints would allow such a selection.)  Instead, the compiler will
generate the default copy assignment operator and call that.

Since the default copy assignment operator would not be correct
(performing a shallow copy), the `__writeable_swizzle__` class must
provide a user defined copy assignment operator.

The copy assignment operator for `__const_swizzle__` was already
deleted in the "constructors" section.  It seemed better to move this
to the "member functions" part of the specification, next to the
specification for the copy assignment operator for
`__writeable_swizzle__`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant