mardi 1 novembre 2016

Collapsing common methods

Is there away to collapse common methods with C++11 templates?

void method( const int, const std::string );
void method( const int, const std::vector< uint8_t > );
void method( const int, const std::string&, const std::multimap< std::string, std::string > );
void method( const int, const std::vector< uint8_t >, const std::multimap< std::string, std::string > );

All of these methods eventual, after converting string to vector< uint8_t >, call:

void method( const int, const std::vector< uint8_t >, std::multimap< std::string, std::string > );

Something like:

template< typename B, typename H = multimap< std::string, std::string > >
    void method( const int, const B = { }, const H = { } );

Aucun commentaire:

Enregistrer un commentaire