Skip to content
Snippets Groups Projects
Commit 3ab1888a authored by Christoph Pohl's avatar Christoph Pohl Committed by ARMAR-DE
Browse files

use perfect forwarding to add skills with non-default constructors

parent 30cb13e8
No related branches found
No related tags found
No related merge requests found
......@@ -46,16 +46,14 @@ namespace armarx::plugins
void addSkill(const skills::LambdaSkill::FunT&, const skills::SkillDescription&);
void addSkill(std::unique_ptr<skills::Skill>&&);
template <typename T>
template <typename T, typename... Args>
T*
addSkill()
addSkill(Args&&... args)
{
static_assert(std::is_base_of<skills::Skill, T>::value,
"T must be derived from skills::Skill!");
static_assert(std::is_default_constructible<T>::value,
"T must be default constructible!");
auto skill = std::make_unique<T>();
auto skill = std::make_unique<T>(std::forward<Args>(args)...);
auto* skillPtr = skill.get();
addSkill(std::move(skill));
return static_cast<T*>(skillPtr);
......@@ -111,11 +109,11 @@ namespace armarx
void addSkill(const skills::LambdaSkill::FunT&, const skills::SkillDescription&);
void addSkill(std::unique_ptr<skills::Skill>&&);
template <typename T>
template <typename T, typename... Args>
T*
addSkill()
addSkill(Args&&... args)
{
return plugin->addSkill<T>();
return plugin->addSkill<T>(std::forward<Args>(args)...);
}
private:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment