Skip to content

Fix xt::drop with variables#2912

Open
Alex-PLACET wants to merge 5 commits into
xtensor-stack:masterfrom
Alex-PLACET:fix_drop_with_variables
Open

Fix xt::drop with variables#2912
Alex-PLACET wants to merge 5 commits into
xtensor-stack:masterfrom
Alex-PLACET:fix_drop_with_variables

Conversation

@Alex-PLACET
Copy link
Copy Markdown
Contributor

@Alex-PLACET Alex-PLACET commented May 6, 2026

Checklist

  • The title and commit message(s) are descriptive.
  • Small commits made to fix your PR have been squashed to avoid history pollution.
  • Tests have been added for new features or bug fixes.
  • API of new functions and classes are documented.

Description

Address #2867

Changed xtl::is_integral<T>::value to xtl::is_integral<std::decay_t<T>>::value in the drop() function template. When passing a variable like size_t index = 1, T deduces to unsigned long&, a reference type, which is_integral rejects. Decaying strips the reference so the integral branch is correctly taken.

@Alex-PLACET Alex-PLACET linked an issue May 6, 2026 that may be closed by this pull request
@Alex-PLACET Alex-PLACET marked this pull request as ready for review May 6, 2026 13:41
inline auto drop(T&& indices)
{
if constexpr (xtl::is_integral<T>::value)
if constexpr (xtl::is_integral<std::decay_t<T>>::value)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if constexpr (xtl::is_integral<std::decay_t<T>>::value)
if constexpr (xtl::is_integral<std::remove_cvref_t<T>>::value)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we should also start to replace all the xtl::is_integral / is_arithmetic and so on with the standard ones. But let's do that in a dedicated PR.

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.

Potential Regression in xt::drop

2 participants