Skip to content

Commit

Permalink
Tweak introduction of swizzled_vec
Browse files Browse the repository at this point in the history
Improve the wording in the introduction of the section on
`__swizzled_vec__` based on review comment feedback.
  • Loading branch information
gmlueck committed Dec 8, 2023
1 parent 64fbeba commit 0271b4e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 5 additions & 4 deletions adoc/chapters/programming_interface.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17638,15 +17638,16 @@ member function template.
==== The [code]#+__swizzled_vec__+# class

The [code]#+__swizzled_vec__+# class is a view over a [code]#vec# object which
reflects a swizzle operation.
captures the effects of a swizzle operation without actually performing that
operation.
The tables below define the interface to this class, but in general it supports
the same interface as [code]#vec#.
Member functions and operators that read elements from the
[code]#+__swizzled_vec__+# return the values of elements from the underlying
[code]#vec# as if it had been modified by the swizzle operation.
[code]#+__swizzled_vec__+# return elements from the underlying [code]#vec# as
translated by the captured swizzle operation.
Member functions and operators that modify elements of the
[code]#+__swizzled_vec__+# modify corresponding elements of the underlying
[code]#vec# as translated by the swizzle operation.
[code]#vec# as translated by the captured swizzle operation.
The following example illustrates this behavior:

[source,,linenums]
Expand Down
2 changes: 2 additions & 0 deletions adoc/code/swizzle-example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ int main() {
int i = v.swizzle<2,1>()[1]; // i has the value 6
v.swizzle<2>() = 0; // v is now {5,6,0,8}
v.swizzle<1>()++; // v is now {5,7,0,8}
v.swizzle<2,3>(); // Has no effect because result of swizzle is
// neither read nor modified
}

0 comments on commit 0271b4e

Please sign in to comment.