Commit ddb98f21 authored by Quentin Khan's avatar Quentin Khan

Push in FVariadicParticleContainer with position and missing attributes

The last attributes may be ommited when pushing in
FVariadicParticleContainer. The last commits broke that behaviour.
parent d1ee4275
......@@ -40,7 +40,8 @@ struct FVariadicParticleContainerBase {
* \tparam Allocator The allocator to use
*
* The Particle type must define an `as_tuple` method that returns a tuple
* representation of the particle. It is expected in general to follow the form:
* representation of the particle. It is expected to hold position values before
* attribute values.
*
* ~~~
* posX, posY, poZ, attributes...
......@@ -118,8 +119,30 @@ public:
*/
template<typename Position, typename... Args>
void push(const Position& position, Args... args) {
Particle temp_part{position, args...};
this->push(temp_part.as_tuple());
using vt = typename FBase::value_type;
constexpr auto Dim = Particle::position_t::Dim;
constexpr int vt_size = std::tuple_size<vt>::value;
constexpr int missing_offset = Dim + sizeof...(args);
constexpr int missing_size = vt_size - missing_offset;
this->push_impl(
inria::make_index_sequence<Dim>{},
inria::make_index_sequence<missing_size>{},
position, args...);
}
template<typename Position, typename... Args, std::size_t... Is, std::size_t... Js, typename... Ts>
void push_impl(inria::index_sequence<Is...>,
inria::index_sequence<Js...>,
const Position& position,
Args... args) {
using vt = typename FBase::value_type;
constexpr auto Dim = Particle::position_t::Dim;
constexpr int missing_offset = Dim + sizeof...(args);
this->push_back(std::get<Is>(position)..., args...,
std::tuple_element_t<missing_offset + Js, vt>{}...);
}
/**
......
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