I have an idea how to simplify remove code repeats. Please help me to understand if it usable, good, and may be let's upgrade.
struct NetAdres
{
/*#1*/NetAdres(const std::string &str, uint16_t port); //#1
/*#2*/NetAdres(std::string &&str, uint16_t port) : NetAdres(std::move(str), port) {}; //#2
/*#3*/NetAdres(const char *str, uint16_t port) : NetAdres(std::string(str), port) {}; //#3
}
This call
NetAdres("192.168.2.3", 80);
as far as I understand calls #3
->#2
->#1
. And this call
NetAdres(std::string("192.168.2.3"), 80);
#2
->#1
. Does such implementation give no extra copy of std::string
?