Skip to content

Potential Regression in xt::drop #2867

@nosracd

Description

@nosracd

There appears to have been a regression in xt::drop between the 0.26.0 and 0.27.0 releases.

Consider the following source code:

#include <xtensor/containers/xarray.hpp>
#include <xtensor/views/xview.hpp>

int main() {
	auto my_array       = xt::xtensor<double, 1>({1, 2, 3});

	// This compiles.
	xt::view(my_array, xt::drop(1));

	// This does not compile in 0.27.0.
	size_t index = 1;
	xt::view(my_array, xt::drop(index));
}

The first xt::drop call builds fine in both versions of xtensor. However, the second xt::drop call fails to compile in xtensor 0.27.0 (but builds fine in 0.26.0). Specifically, I get a compiler error like:

views/xslice.hpp:506:46: error: type 'decay_t<unsigned long &>' (aka 'unsigned long') cannot be used prior to '::' because it has no members
  506 |             return xdrop_slice<typename std::decay_t<T>::value_type>(std::forward<T>(indices));
      |                                         ~~~~~^
../xtensor_test.cpp:12:25: note: in instantiation of function template specialization 'xt::drop<long, unsigned long &>' requested here
   12 |         xt::view(my_array, xt::drop(index));
      |                                ^
1 error generated.

The compiler error happens for other integer types (e.g. int) as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions