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

Add rvalue qualified xstrided_view_base::storage #2413

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions include/xtensor/xstrided_view_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,9 @@ namespace xt
template <class It>
const_reference element(It first, It last) const;

storage_type& storage() noexcept;
const storage_type& storage() const noexcept;
storage_type& storage() & noexcept;
const storage_type& storage() const & noexcept;
storage_type&& storage() && noexcept;

template <class E = xexpression_type, class ST = storage_type>
std::enable_if_t<detail::provides_data_interface<E, ST>::value, pointer>
Expand Down Expand Up @@ -550,7 +551,7 @@ namespace xt
* Returns a reference to the buffer containing the elements of the view.
*/
template <class D>
inline auto xstrided_view_base<D>::storage() noexcept -> storage_type&
inline auto xstrided_view_base<D>::storage() & noexcept -> storage_type&
{
return m_storage;
}
Expand All @@ -559,11 +560,21 @@ namespace xt
* Returns a constant reference to the buffer containing the elements of the view.
*/
template <class D>
inline auto xstrided_view_base<D>::storage() const noexcept -> const storage_type&
inline auto xstrided_view_base<D>::storage() const & noexcept -> const storage_type&
{
return m_storage;
}

/**
* Returns a rvalue reference to the buffer containing the elements of the view.
*/
template <class D>
inline auto xstrided_view_base<D>::storage() && noexcept -> storage_type&&
{
return std::move(m_storage);
}


/**
* Returns a pointer to the underlying array serving as element storage.
* The first element of the view is at data() + data_offset().
Expand Down