mardi 13 octobre 2020

std::function Through type is not allowed

I Need to perform a unit test on AddToDB() API. Below is my Attemp but i get error when i create a callback with notify type 2 mention below

  1. typedef std::function<bool(std::string)> strnotify;
  2. typedef std::function<void(strnotify &)> notify;
  3. bool AddToDB(notify data);
// callback for typedef std::function<bool(std::string)> strnotify;
   bool StringNotify(std::string){
     std::cout<<"String success";
     return true;
   }
   
   //  callback for typedef std::function<void(strnotify &)> notify;
   void StringObject(strnotify & obj){ // i get error here as type is not allowed
    std::cout<<"string obj success";
   }
   
   //Call to API 
   AddToDB(StringObject)

I get error as type is not allowed.

Aucun commentaire:

Enregistrer un commentaire