Tell me how in c ++ 11 you can implement the following functionality:
1) I have a data filtering function
typedef bool(*filteredFunc)(const CPacketData&);
which I will use to process the input
2) there is a structure containing data processing parameters (input conditions, output data)
struct CStatisticsData { // служебная информация filteredFunc m_filteredFunc; // статистика CStatistics m_output; CStatisticsData(const filteredFunc filteredFunc); }; 3) data is processed in different ways, therefore, the input parameters and output data are different, but everything is stored in the same vector
typedef std::vector<CStatisticsData> data_t; which I pre-fill as follows:
data_t allData; allData.push(CStatisticsData(myFunc1)); allData.push(CStatisticsData(myFunc2)); allData.push(CStatisticsData(myFunc3)); and the functions themselves myFunc1 , myFunc2 , myFunc3 describe above
Question:
since the functions are small, I would like for clarity to place them immediately in initialization, as in JS:
data_t allData; allData.push(CStatisticsData(function(params){ return (params.name == 'x'); })); Tell me how to do it right? As I understand it, in essence, lambda functions, but they are probably differently set and used than ordinary functions as parameters?