Код: Выделить всё
template
struct ParameterUnpacker
{
public:
template
static std::tuple UnpackParametersHelper(ParameterPack& parameters, std::index_sequence)
{
// the ParameterPack is basically a container that stores a bunch of TypeErasedParameters.
// it has a function to get the parameter by ID:
// GetParameter(std::string& parameterID)
// so the ParameterPack is ultimately a container for the parameters in Args...
// TODO: Return a tuple of the parameters by matching the Ids with the Is order of the parameters, so this next line is where im not sure whether things are correct
return std::make_tuple((parameters.GetParameter(vecParameterIdsAndDefaultVals.at(Is).first)) ...);
}
static std::tuple UnpackParameters(ParameterPack& parameters)
{
// parameters contains as many Ids and types as Args...
return UnpackParametersHelper(parameters, std::index_sequence_for{});
}
};
int main(int argc, char* argv[])
{
// create ParameterPack...
int intParam = 12;
double doubleParam = 2.4;
auto parameterPack = MagicallyCreateParameterPack(doubleParam, intParam);
// this is how I want to be able to access the parameters:
auto&[doubleparam, intparam] = ParameterUnpacker::UnpackParameters(parameterPack);
return 0;
}
ошибка C2664: "std::tuple ParameterUnpacker< double,int>::UnpackParameters(ParameterPack &)" : преобразование аргумента 1 из "std::vectorstd::string,std::allocator" в "ParameterPack &" невозможно
Заранее большое спасибо, дайте мне знать, если вам понадобится дополнительная информация!
Подробнее здесь: https://stackoverflow.com/questions/781 ... he-paramet