Commit 5c05c1d5 authored by Quentin Khan's avatar Quentin Khan

Basic/Variadic Containers: move methods from basic to variadic

parent 439c9c63
......@@ -50,11 +50,43 @@ public:
FBase::clear();
}
/** \brief Push a particle in the conainer
*
* \param particle Particle to push
*/
void push(const Particle& particle) {
this->push_back(static_cast<typename Particle::data_t>(particle));
}
/** \brief Push a particle in the container
*
* \tparam Args Parameter pack of types convertible to the Attribute type.
*
* \note The pack size must be at most AttributeCount, if it is less,
* the remaining attributes are zero constructed (i.e. `Attribute(0)`
* is called to build them).
*
* \param position The particle position
* \param args The particle attributes
*/
template<typename... Args>
void push(const FPoint<FReal>& position, Args... args) {
this->push(Particle(position, args...));
}
/*
template<typename... Ts>
void push(const position_t& pos, Ts&&... args) {
this->push_impl(std::make_index_sequence<position_t::Dim>(),
pos, std::forward<Ts>(args)...);
}
template<typename... Ts, std::size_t... Is>
void push_impl(std::index_sequence<Is...>, const position_t& pos, Ts&&... args) {
this->push_back(pos[Is]..., std::forward<Ts>(args)...);
}
*/
};
......
......@@ -226,14 +226,6 @@ public:
using FBase::push;
/** \brief Push a particle in the conainer
*
* \param particle Particle to push
*/
void push(const value_type& particle) {
this->push(particle.position(), std::get<attrIndices>(particle.attributes())...);
}
/** \brief Push a particle in the container
*
......@@ -246,13 +238,13 @@ public:
* \param position The particle position
* \param args The particle attributes
*/
template<typename... Args>
void push(const FPoint<FReal>& position, Args... args) {
this->push_helper(
std::make_index_sequence<AttributeCount+OtherCount-sizeof...(args)>(),
position, args...
);
}
// template<typename... Args>
// void push(const FPoint<FReal>& position, Args... args) {
// this->push_helper(
// std::make_index_sequence<AttributeCount+OtherCount-sizeof...(args)>(),
// position, args...
// );
// }
/** \brief Helper function for push
*
......@@ -268,10 +260,10 @@ public:
* \param position Particle position
* \param args Particle attributes
*/
template<typename... Args, std::size_t... Is>
void push_helper(std::index_sequence<Is...>, const FPoint<FReal>& position, Args&&... args) {
FBase::push_back(std::get<posIndices>(position)..., std::forward<Args>(args)..., ((void)Is,Attribute(0))...);
}
// template<typename... Args, std::size_t... Is>
// void push_helper(std::index_sequence<Is...>, const FPoint<FReal>& position, Args&&... args) {
// FBase::push_back(std::get<posIndices>(position)..., std::forward<Args>(args)..., ((void)Is,Attribute(0))...);
// }
/** \brief Push a particle in the container (array attributes)
*
......
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