Skip to content
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

No matching conversion xt::keep(...) #2036

Open
tdegeus opened this issue Apr 21, 2020 · 4 comments
Open

No matching conversion xt::keep(...) #2036

tdegeus opened this issue Apr 21, 2020 · 4 comments

Comments

@tdegeus
Copy link
Member

@tdegeus tdegeus commented Apr 21, 2020

The following example:

#include <xtensor/xtensor.hpp>
#include <xtensor/xview.hpp>
#include <xtensor/xio.hpp>

int main()
{
    xt::xtensor<size_t,1> a = {1, 2, 1, 0, 3, 1};
    xt::xtensor<size_t,1> idx = {0, 3};
    xt::xtensor<size_t,1> jdx = {1, 2};
    auto b = xt::view(a, xt::keep(idx + jdx));
    return 0;
}

Fails to compile:

In file included from /Users/tdegeus/Downloads/test/xtensor/main.cpp:1:
In file included from /Users/tdegeus/miniconda3/envs/stable/include/xtensor/xtensor.hpp:20:
In file included from /Users/tdegeus/miniconda3/envs/stable/include/xtensor/xcontainer.hpp:24:
In file included from /Users/tdegeus/miniconda3/envs/stable/include/xtensor/xmath.hpp:28:
In file included from /Users/tdegeus/miniconda3/envs/stable/include/xtensor/xmanipulation.hpp:13:
In file included from /Users/tdegeus/miniconda3/envs/stable/include/xtensor/xbuilder.hpp:34:
In file included from /Users/tdegeus/miniconda3/envs/stable/include/xtensor/xgenerator.hpp:27:
In file included from /Users/tdegeus/miniconda3/envs/stable/include/xtensor/xstrided_view.hpp:27:
In file included from /Users/tdegeus/miniconda3/envs/stable/include/xtensor/xstrided_view_base.hpp:19:
/Users/tdegeus/miniconda3/envs/stable/include/xtensor/xslice.hpp:395:16: error: no matching conversion for functional-style cast from
      'xt::xfunction<xt::detail::plus, const xt::xtensor_container<xt::uvector<unsigned long, std::__1::allocator<unsigned long> >, 1,
      xt::layout_type::row_major, xt::xtensor_expression_tag> &, const xt::xtensor_container<xt::uvector<unsigned long,
      std::__1::allocator<unsigned long> >, 1, xt::layout_type::row_major, xt::xtensor_expression_tag> &>' to 'xkeep_slice<typename
      std::decay_t<xfunction<plus, const xtensor_container<uvector<unsigned long, allocator<unsigned long> >, 1, xt::layout_type::row_major,
      xtensor_expression_tag> &, const xtensor_container<uvector<unsigned long, allocator<unsigned long> >, 1, xt::layout_type::row_major,
      xtensor_expression_tag> &> >::value_type>' (aka 'xkeep_slice<unsigned long>')
        return xkeep_slice<typename std::decay_t<T>::value_type>(std::forward<T>(indices));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/tdegeus/Downloads/test/xtensor/main.cpp:10:30: note: in instantiation of function template specialization
      'xt::keep<xt::xfunction<xt::detail::plus, const xt::xtensor_container<xt::uvector<unsigned long, std::__1::allocator<unsigned long> >,
      1, xt::layout_type::row_major, xt::xtensor_expression_tag> &, const xt::xtensor_container<xt::uvector<unsigned long,
      std::__1::allocator<unsigned long> >, 1, xt::layout_type::row_major, xt::xtensor_expression_tag> &> >' requested here
    auto b = xt::view(a, xt::keep(idx + jdx));
                             ^
/Users/tdegeus/miniconda3/envs/stable/include/xtensor/xslice.hpp:321:11: note: candidate constructor (the implicit copy constructor) not
      viable: no known conversion from 'xt::xfunction<xt::detail::plus, const xt::xtensor_container<xt::uvector<unsigned long,
      std::__1::allocator<unsigned long> >, 1, xt::layout_type::row_major, xt::xtensor_expression_tag> &, const
      xt::xtensor_container<xt::uvector<unsigned long, std::__1::allocator<unsigned long> >, 1, xt::layout_type::row_major,
      xt::xtensor_expression_tag> &>' to 'const xt::xkeep_slice<unsigned long>' for 1st argument
    class xkeep_slice : public xslice<xkeep_slice<T>>
          ^
/Users/tdegeus/miniconda3/envs/stable/include/xtensor/xslice.hpp:321:11: note: candidate constructor (the implicit move constructor) not
      viable: no known conversion from 'xt::xfunction<xt::detail::plus, const xt::xtensor_container<xt::uvector<unsigned long,
      std::__1::allocator<unsigned long> >, 1, xt::layout_type::row_major, xt::xtensor_expression_tag> &, const
      xt::xtensor_container<xt::uvector<unsigned long, std::__1::allocator<unsigned long> >, 1, xt::layout_type::row_major,
      xt::xtensor_expression_tag> &>' to 'xt::xkeep_slice<unsigned long>' for 1st argument
    class xkeep_slice : public xslice<xkeep_slice<T>>
          ^
/Users/tdegeus/miniconda3/envs/stable/include/xtensor/xslice.hpp:330:18: note: candidate constructor [with C =
      xt::xfunction<xt::detail::plus, const xt::xtensor_container<xt::uvector<unsigned long, std::__1::allocator<unsigned long> >, 1,
      xt::layout_type::row_major, xt::xtensor_expression_tag> &, const xt::xtensor_container<xt::uvector<unsigned long,
      std::__1::allocator<unsigned long> >, 1, xt::layout_type::row_major, xt::xtensor_expression_tag> &>, $1 = void] not viable: expects an
      l-value for 1st argument
        explicit xkeep_slice(C& cont);
                 ^
/Users/tdegeus/miniconda3/envs/stable/include/xtensor/xslice.hpp:331:18: note: candidate constructor not viable: no known conversion from
      'xt::xfunction<xt::detail::plus, const xt::xtensor_container<xt::uvector<unsigned long, std::__1::allocator<unsigned long> >, 1,
      xt::layout_type::row_major, xt::xtensor_expression_tag> &, const xt::xtensor_container<xt::uvector<unsigned long,
      std::__1::allocator<unsigned long> >, 1, xt::layout_type::row_major, xt::xtensor_expression_tag> &>' to 'xt::xkeep_slice<unsigned
      long>::container_type' (aka 'svector<unsigned long>') for 1st argument
        explicit xkeep_slice(container_type&& cont);
                 ^
/Users/tdegeus/miniconda3/envs/stable/include/xtensor/xslice.hpp:334:9: note: candidate template ignored: could not match 'initializer_list'
      against 'xfunction'
        xkeep_slice(std::initializer_list<S> t);
        ^
/Users/tdegeus/miniconda3/envs/stable/include/xtensor/xslice.hpp:359:9: note: candidate constructor not viable: requires 0 arguments, but 1
      was provided
        xkeep_slice() = default;
        ^
1 error generated.
@tdegeus tdegeus changed the title No matching conversion No matching conversion xt::keep(...) Apr 21, 2020
@tdegeus
Copy link
Member Author

@tdegeus tdegeus commented Apr 21, 2020

Similarly xt::keep(xt::view(...)) does not work

@JohanMabille
Copy link
Member

@JohanMabille JohanMabille commented Apr 21, 2020

Indeed, xt::keep is not supposed to work on xexpression objects.

@tdegeus
Copy link
Member Author

@tdegeus tdegeus commented Apr 21, 2020

Is there a reason to allow this?

@JohanMabille
Copy link
Member

@JohanMabille JohanMabille commented Apr 21, 2020

I think this was mainly to avoid circular dependencies. And also because xt::keep are basic building blocs for views, so it would be weird to have them depend on it. I guess we could add a constructor that accepts a pair of iterators, so it would be possible to sintantiate it from any kind of expression

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.