Skip to content

Fixed build break on Debian 11 with recent OS SYCL bundle #1118

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

Merged
merged 1 commit into from
Mar 13, 2023
Merged
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
20 changes: 14 additions & 6 deletions dpctl/tensor/libtensor/source/boolean_advanced_indexing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,36 +44,44 @@ namespace tensor
namespace py_internal
{

namespace concat_impl
{

struct sink_t
{
sink_t(){};
template <class T> sink_t(T &&){};
};

template <class V> std::size_t accumulate_size(std::size_t &s, V &&v)
template <class V> std::size_t __accumulate_size(std::size_t &s, V &&v)
{
return s += v.size();
}

template <class V, class U> sink_t inserter(V &lhs, U &&rhs)
template <class V, class U> sink_t __appender(V &lhs, U &&rhs)
{
lhs.insert(lhs.end(), rhs.begin(), rhs.end());
return {};
}

} // namespace concat_impl

template <typename T, typename A, typename... Vs>
std::vector<T, A> concat(std::vector<T, A> lhs, Vs &&...vs)
{
using concat_impl::__accumulate_size;
using concat_impl::__appender;
using concat_impl::sink_t;
std::size_t s = lhs.size();
{
// limited scope ensures array is freed
[[maybe_unused]] sink_t tmp[] = {accumulate_size(s, vs)..., 0};
[[maybe_unused]] sink_t tmp[] = {__accumulate_size(s, vs)..., 0};
}
lhs.reserve(s);
{
// array of no-data objects ensures ordering of calls to inserter
[[maybe_unused]] sink_t tmp[] = {inserter(lhs, std::forward<Vs>(vs))...,
0};
// array of no-data objects ensures ordering of calls to the appender
[[maybe_unused]] sink_t tmp[] = {
__appender(lhs, std::forward<Vs>(vs))..., 0};
}

return std::move(lhs); // prevent return-value optimization
Expand Down