-
Notifications
You must be signed in to change notification settings - Fork 410
Adding concept to a part of the code (part 2) #2846
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
base: master
Are you sure you want to change the base?
Adding concept to a part of the code (part 2) #2846
Conversation
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) |
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.
Nitpicking: std::is_pointer_v<T>
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.
There is no stl concept for pointer, maybe I can create one for the xtl and use it.
{ | ||
return e; | ||
if constexpr (std::is_pointer<T>::value) |
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.
Same here.
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>; |
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.
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>; |
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.
Same remark here.
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>; |
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.
Same here.
include/xtensor/views/xslice.hpp
Outdated
inline xdrop_slice<T>::operator xdrop_slice<S>() const noexcept | ||
requires std::convertible_to<S, T> |
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.
Same here.
include/xtensor/views/xslice.hpp
Outdated
inline xdrop_slice<S> xdrop_slice<T>::convert() const noexcept | ||
requires std::convertible_to<S, T> |
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.
Same here.
@@ -180,6 +180,9 @@ namespace xt | |||
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 |
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 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) |
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.
You can use std::is_signed_v
@@ -133,6 +133,9 @@ namespace xt | |||
static constexpr bool contiguous_layout = static_layout != layout_type::dynamic | |||
&& xexpression_type::contiguous_layout; | |||
|
|||
static constexpr bool | |||
providedDataInterface = detail::provides_data_interface<xexpression_type, storage_type>::value; |
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 should be snake_case ;)
Checklist
Description
This PR C++20's concept and C++17's if constexpr to a moderatly large chunk of xtensor.