-
Notifications
You must be signed in to change notification settings - Fork 152
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
Mask, Vector, and Simd[Mask]Array::operator[] should return a smart reference (proxy) #115
Comments
mattkretz
added a commit
that referenced
this issue
Mar 23, 2016
* Test SimdArray, too * Rewrite the `write` test because of the odd sizes of SimdArray * Added a iterateNumericRange generator to simplify test code, in this case the `write` test. * Ensure no copy/move possible from non-const v[i] * Ensure copy/move possible from const v[i] * Ensure compound assignment works as expected for the underlying value_type Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 23, 2016
ElementReference<T> acts as much as possible like an lvalue reference of T::value_type. It has: * all move and copy ctors and assignment deleted, and * an rvalue ref-qualifier on all assignment and in-/decrement operators to limit the use of the proxy type as much as possible. The intent is to either copy to value_type or to modify the referenced element directly, i.e. without going through an lvalue. The noexcept specification is derived from the noexcept-ness of the Accessor functions to the original container/vector. Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 23, 2016
Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 23, 2016
Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 23, 2016
Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 23, 2016
Port all implementations & SimdArray to use Detail::ElementReference as return type for non-const operator[]. const operator[] returns a value_type copy directly. This change removes the need to return lvalue references that alias memory of VectorType. In addition this change introduces noexcept specifications for all functions related to operator[]. The special case for short vectors on MIC are obsolete now because of the explicit conversion to value_type on Vector::get. Also dropped the optimized implementation of __builtin_constant_p operator[] for GCC. As far as I've seen GCC can do these optimizations by itself now. Fixes: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 23, 2016
ElementReference<T> acts as much as possible like an lvalue reference of T::value_type. It has: * all move and copy ctors and assignment deleted, and * an rvalue ref-qualifier on all assignment and in-/decrement operators to limit the use of the proxy type as much as possible. The intent is to either copy to value_type or to modify the referenced element directly, i.e. without going through an lvalue. The noexcept specification is derived from the noexcept-ness of the Accessor functions to the original container/vector. Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 23, 2016
Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 23, 2016
Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 23, 2016
Port all implementations & SimdArray to use Detail::ElementReference as return type for non-const operator[]. const operator[] returns a value_type copy directly. This change removes the need to return lvalue references that alias memory of VectorType. In addition this change introduces noexcept specifications for all functions related to operator[]. The special case for short vectors on MIC are obsolete now because of the explicit conversion to value_type on Vector::get. Also dropped the optimized implementation of __builtin_constant_p operator[] for GCC. As far as I've seen GCC can do these optimizations by itself now. Fixes: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 30, 2016
The noexcept operator SFINAEs if the expression in it is invalid. Therefore the enable_if only needs to do the function argument count. Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 30, 2016
Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 30, 2016
Otherwise the types of the std::tuple would be Detail::ElementReference, which would be a very bad idea. Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 30, 2016
Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 30, 2016
This change is required because non-const operator[] of vector types returns ElementReference now. Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 30, 2016
This test is important *now* since the Vector::operator[] doesn't return lvalue references anymore. This changes the iterators category to InputIterator. At the same time the iterator should still support as much as possible of the RandomAccessIterator interface. Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 30, 2016
After Vector & Mask return ElementReference on operator[] iterators can not return an lvalue reference on operator* and thus only implement InputIterator and OutputIterator. Consequently, the unit test should only test that range-for works for InputIterator. Moved the test to iterators.cpp from utils.cpp since that is the natural place for it now. Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 30, 2016
Ensure that unary !, +, -, and ~ work with expressions of Vector::operator[]. Though, ~ should only work for integral types. Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 30, 2016
Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 30, 2016
Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 30, 2016
* Dropped MaskEntry, which was a specialized ElementReference for Mask * Dropped setEntry members in Mask types (remnant of MaskEntry) * Added member type `reference` to all Mask types * Declared Mask subscripting noexcept; conditional where it possibly calls user code * Changed SSE::Mask to return bool via MaskBool conversion instead of going via toInt() Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 30, 2016
* Set iterator_category to input_iterator_tag * Make Iterator DefaultConstructible and CopyAssignable * Implement all RandomAccessIterator operations * Fix const-correctness (i.e. const mutable iterators still point to mutable data) * Drop the std::iterator base: It was useless and inflexible Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 30, 2016
This works around the question of constexpr on the function which clang 3.5.0 and GCC 4.8 reject (old C++11 rules implied the const qualifier). Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 30, 2016
Apple clang complains about the variadic template parameter on operator++/-- (for no good reason, IMHO). Using a defaulted template parameter should make this more portable, though. Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
mattkretz
added a commit
that referenced
this issue
Mar 30, 2016
The operator[] change lead to an internal compiler error in clang 3.5. Reimplementing SimdMaskArray::shifted with SimdMaskArray::generate makes the code nicer to read/understand and successfully works around the ICE in clang. Refs: gh-115 Signed-off-by: Matthias Kretz <kretz@kde.org>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feedback on P0214R0 from SG1 was to leave type punning alone and return a smart ref / rvalue
value_type
fromoperator[]
(const
).The text was updated successfully, but these errors were encountered: