I get the Erro:
"no instance of constructor "std::vector<_Ty, _Alloc>::vector 
 [with _Ty=FunctionToUpdate, _Alloc=std::allocator<FunctionToUpdate>]" matches the argument list" 
No matter how I change it, it persists, as long I keep it as a class. If I keep it all in just a simple .cpp without class and header, it all resolves easily. My.h:
#include <vector>
#include <functional>
#include <iostream>
struct Params
{
    std::vector<int> Integers;
    std::vector<std::string> Strings;
};
struct FunctionToUpdate
{
    int Version;
    std::function<void(int, Params)> Function;
    Params Parameters;
};
class Error
{
public:
    Error();
    void testFunctionA(int a, Params p);
    void testFunctionB(int a, Params p);
protected:
    const static std::vector<FunctionToUpdate> table;
};
Here is my .cpp, please assist me, I can't find the error:
#include "ErrorHandling.h"
Error::Error()
{
    for (auto functionToUpdate : table)
    {
        functionToUpdate.Function(functionToUpdate.Version, functionToUpdate.Parameters);
        std::cout << "############################################" << std::endl;
    }
    std::cout << "Done!" << std::endl;
}
void Error::testFunctionA(int a, Params parameter)
{
    //std::cout << "Size Integers: " << parameter.Integers.size() << std::endl;
    //std::cout << "Size Strings: " << parameter.Strings.size() << std::endl;
    std::cout << a << std::endl;
    for (auto& integer : parameter.Integers)
    {
        std::cout << integer << std::endl;
    }
    for (auto& integer : parameter.Strings)
    {
        std::cout << integer << std::endl;
    }
}
void Error::testFunctionB(int a, Params parameter)
{
    std::cout << a << std::endl;
    std::cout << parameter.Integers.at(0) << std::endl;
}
const std::vector<FunctionToUpdate> Error::table
{                                                       // <-- here the Error happens
    { 100, &testFunctionA, { {177}}},
    { 1948, &testFunctionB, { {314}}},
};
int main()
{
    Error error;
}
Aucun commentaire:
Enregistrer un commentaire