Skip to content

xt::xstrided_slice<std::ptrdiff_t> are not comparable #257

@jblespiau

Description

@jblespiau

It's as simple as doing:

xt::all() == xt::all()

experimental/users/jblespiau/tensorfn/pybind11/pmap_function.cc:72:30: error: invalid operands to binary expression ('xt::xall_tag' and 'xt::xall_tag')
          bool c = xt::all() == xt::all();
                   ~~~~~~~~~ ^  ~~~~~~~~~
./third_party/xtensor/xutils.hpp:737:17: note: candidate template ignored: could not match 'tracking_allocator<T, AT, PT>' against 'xt::xall_tag'
    inline bool operator==(const tracking_allocator<T, AT, PT>&, const tracking_allocator<U, AU, PU>&)
                ^
./third_party/xtensor/xstorage.hpp:545:17: note: candidate template ignored: could not match 'uvector<T, A>' against 'xt::xall_tag'
    inline bool operator==(const uvector<T, A>& lhs, const uvector<T, A>& rhs)
                ^
./third_party/xtensor/xstorage.hpp:1270:17: note: candidate template ignored: could not match 'std::vector<T>' against 'xt::xall_tag'
    inline bool operator==(const std::vector<T>& lhs, const svector<T, N, A, Init>& rhs)
                ^
./third_party/xtensor/xstorage.hpp:1276:17: note: candidate template ignored: could not match 'svector<T, N, A, Init>' against 'xt::xall_tag'
    inline bool operator==(const svector<T, N, A, Init>& lhs, const std::vector<T>& rhs)
                ^
experimental/users/jblespiau/tensorfn/pybind11/pmap_function.cc:72:30: note: remaining 9 candidates omitted; pass -fshow-overloads=all to show them
          bool c = xt::all() == xt::all();

The type is defined as:

    template <class T>
    using xstrided_slice = xtl::variant<
        T,

        xrange_adaptor<placeholders::xtuph, T, T>,
        xrange_adaptor<T, placeholders::xtuph, T>,
        xrange_adaptor<T, T, placeholders::xtuph>,

        xrange_adaptor<T, placeholders::xtuph, placeholders::xtuph>,
        xrange_adaptor<placeholders::xtuph, T, placeholders::xtuph>,
        xrange_adaptor<placeholders::xtuph, placeholders::xtuph, T>,

        xrange_adaptor<T, T, T>,
        xrange_adaptor<placeholders::xtuph, placeholders::xtuph, placeholders::xtuph>,

        xrange<T>,
        xstepped_range<T>,

        xall_tag,
        xellipsis_tag,
        xnewaxis_tag
    >;

As a side-note, I was wondering if we should upgrade to C++ 17 to use std::variant instead of a backport. Another altnertive would be to use e.g. https://github.com/abseil/abseil-cpp/blob/master/absl/types/variant.h which will be an alias to std::variant when available.

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