dimanche 20 août 2017

c++ decltype how to use to simplify variable definition

Say, I have this piece of code, in one of my classes, that defines

  • A map of key and another map
  • The second map is another key and a function handler
  • The function hander is a signature that takes 2 params

Right now, the signature to define the variable looks incredible.

std::map<std::string, std::map<std::string,
    std::function<void(std::shared_ptr<HTTPRequest>,
        std::shared_ptr<HTTPResponse>)>>> routeFunctions_;

I recently came to know about decltype, but unable to use this correctly.

decltype(x) routeFunctions_;  // What should be there in the place of x ?

Aucun commentaire:

Enregistrer un commentaire