allwpilib
allwpilib copied to clipboard
Problems Creating SelectCommand from lambda function and std::vector<std::pair<std::string, std::unique_ptr<frc2::Command>>>
I am trying to create a SelectCommand at runtime. The commands are created by reading a json file during RobotInit.
Code:
#include <frc2/command/Commands.h>
#include <frc2/command/SelectCommand.h>
frc2::CommandPtr createSelectCommand(std::function<std::string()> selector
, std::vector<std::pair<std::string, std::unique_ptr<frc2::Command>>> &&commands) {
return frc2::SelectCommand(selector, commands).ToPtr();
}
/*
// commandSelector returns a std::string
[this, commandSelector]() -> std::string { return commandSelector();}
*/
Line 76 of the file SelectCommand.h specifies a templated constructor that seems to match my parameters, but I have not found a way to have the compiler correctly compile the code.
I get the following errors:
cannot deduce class template arguments
no instance of constructor "SelectCommand" matches the argument list argument types are: (std::function<std::string ()>, std::vector<std::pair<std::string, std::unique_ptr<frc2::Command, std::default_delete<frc2::Command>>>, std::allocator<std::pair<std::string, std::unique_ptr<frc2::Command, std::default_delete<frc2::Command>>>>>)