Adding concept to a part of the code (part 2)#2846
Merged
JohanMabille merged 3 commits intoxtensor-stack:masterfrom Jul 12, 2025
Merged
Adding concept to a part of the code (part 2)#2846JohanMabille merged 3 commits intoxtensor-stack:masterfrom
JohanMabille merged 3 commits intoxtensor-stack:masterfrom
Conversation
added 2 commits
April 15, 2025 13:58
| inline std::enable_if_t<!std::is_pointer<T>::value, T> xaxis_iterator<CT>::get_storage_init(CTA&& e) const | ||
| { | ||
| return e; | ||
| if constexpr (std::is_pointer<T>::value) |
Member
There was a problem hiding this comment.
Nitpicking: std::is_pointer_v<T>
Contributor
Author
There was a problem hiding this comment.
There is no stl concept for pointer, maybe I can create one for the xtl and use it.
| T xaxis_slice_iterator<CT>::get_storage_init(CTA&& e) const | ||
| { | ||
| return e; | ||
| if constexpr (std::is_pointer<T>::value) |
include/xtensor/views/xslice.hpp
Outdated
| operator xrange<S>() const noexcept; | ||
| template <class S> | ||
| operator xrange<S>() const noexcept | ||
| requires std::convertible_to<S, T>; |
Member
There was a problem hiding this comment.
You can shorten the declaration with:
template <std::convertible_to<T> S>
operator xrange<S>() const noexcept;Here S will be passed as the first argument of the concept used in the type constraint.
include/xtensor/views/xslice.hpp
Outdated
| xrange<S> convert() const noexcept; | ||
| template <class S> | ||
| xrange<S> convert() const noexcept | ||
| requires std::convertible_to<S, T>; |
include/xtensor/views/xslice.hpp
Outdated
| operator xstepped_range<S>() const noexcept; | ||
| template <class S> | ||
| operator xstepped_range<S>() const noexcept | ||
| requires std::convertible_to<S, T>; |
include/xtensor/views/xslice.hpp
Outdated
| template <class S, typename> | ||
| template <class S> | ||
| inline xdrop_slice<T>::operator xdrop_slice<S>() const noexcept | ||
| requires std::convertible_to<S, T> |
include/xtensor/views/xslice.hpp
Outdated
| template <class S, typename> | ||
| template <class S> | ||
| inline xdrop_slice<S> xdrop_slice<T>::convert() const noexcept | ||
| requires std::convertible_to<S, T> |
| using simd_value_type = xt_simd::simd_type<value_type>; | ||
| using bool_load_type = typename base_type::bool_load_type; | ||
|
|
||
| static constexpr bool providedSimdInterface = has_simd_interface<xexpression_type>::value |
Member
There was a problem hiding this comment.
This should be snake_case ;)
| XTENSOR_ASSERT(std::count(shape.cbegin(), shape.cend(), -1) <= 1); | ||
| auto iter = std::find(shape.begin(), shape.end(), -1); | ||
| if (iter != std::end(shape)) | ||
| if constexpr (std::is_signed<get_value_type_t<typename std::decay<S>::type>>::value) |
Member
There was a problem hiding this comment.
You can use std::is_signed_v
| && xexpression_type::contiguous_layout; | ||
|
|
||
| static constexpr bool | ||
| providedDataInterface = detail::provides_data_interface<xexpression_type, storage_type>::value; |
Member
There was a problem hiding this comment.
This should be snake_case ;)
JohanMabille
approved these changes
Apr 28, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
Description
This PR C++20's concept and C++17's if constexpr to a moderatly large chunk of xtensor.