Commit 65025e1a authored by Philip Trettner's avatar Philip Trettner
Browse files

fixed span for ref types, copy_from with spans

parent 7679582c
......@@ -7,6 +7,7 @@
#include <polymesh/cursors.hh>
#include <polymesh/detail/unique_array.hh>
#include <polymesh/ranges.hh>
#include <polymesh/span.hh>
#include <polymesh/tmp.hh>
#include <polymesh/view.hh>
......@@ -121,8 +122,8 @@ public:
// template <class ReadT, class WriteT>
// void view(ReadT&& r, WriteT&& w) && = delete;
/// copies as much data as possible from the given vector
void copy_from(std::vector<AttrT> const& data);
/// copies as much data as possible from the given range of data
void copy_from(span<AttrT const> data);
/// copies as much data as possible from the given array
void copy_from(AttrT const* data, int cnt);
/// copies as much data as possible from the given attribute
......
......@@ -63,7 +63,7 @@ AttrT const& edge_attribute<AttrT>::operator()(halfedge_handle h) const
}
template <class tag, class AttrT>
void primitive_attribute<tag, AttrT>::copy_from(std::vector<AttrT> const& data)
void primitive_attribute<tag, AttrT>::copy_from(span<AttrT const> data)
{
std::copy_n(data.data(), std::min(int(data.size()), this->size()), this->data());
}
......
......@@ -103,9 +103,11 @@ struct constant_rational
namespace detail
{
template <class Container, class ElementT>
auto contiguous_range_test(Container* c) -> decltype(static_cast<ElementT*>(c->data()), static_cast<size_t>(c->size()), 0);
auto contiguous_range_test(int) -> decltype(static_cast<ElementT*>(std::declval<Container>().data()), //
static_cast<size_t>(std::declval<Container>().size()),
std::true_type{});
template <class Container, class ElementT>
char contiguous_range_test(...);
std::false_type contiguous_range_test(char);
template <class Container, class ElementT, class = void>
struct is_range_t : std::false_type
......@@ -139,7 +141,7 @@ struct is_range_t<Container,
}
template <class Container, class ElementT>
static constexpr bool is_contiguous_range = sizeof(detail::contiguous_range_test<Container, ElementT>(nullptr)) == sizeof(int);
static constexpr bool is_contiguous_range = decltype(detail::contiguous_range_test<Container, ElementT>(0))::value;
template <class Container, class ElementT>
static constexpr bool is_range = detail::is_range_t<Container, ElementT>::value;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment