This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Super duper automatic | |
auto f1 = [&b](auto v) { | |
return v*b; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//More restrict | |
auto f2 = [&b](auto v) -> decltype(v*b) { | |
return v*b; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//very restrict | |
auto f3 = [&b](int v) -> int { | |
return v*b; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fix_parser parser; | |
msg_transport::received_msg(transport, [&m](auto &data) { | |
message m = parser.get_msg(data); | |
processor.new_msg(m); | |
}); | |
msg_transport::received_cmd(transport, [&m](auto &data) { | |
command c = parser.get_msg(data); | |
admin.new_msg(c); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[&b](auto v) { | |
return v*b; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Construtor padrão | |
TestCopy() { | |
cout << "[CONSTR 1]" << endl; | |
this->val = 0; | |
} | |
//Construtor parametrizado | |
TestCopy(T val) { | |
cout << "[CONSTR 2:" << val << "]" << endl; | |
this->val = val; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TestCopy(T val) { | |
cout << "[CONSTR 2:" << val << "]" << endl; | |
this->val = val; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Saída do programa: | |
TestCopy<> t1; //[CONSTR 1] | |
TestCopy<> t2 {1}; //[CONSTR 2:1] | |
TestCopy<> t3 = t2; //[COPY] | |
TestCopy<> t4 {t2}; //[COPY] | |
TestCopy<> t5 = TestCopy<>{5}; //[CONSTR 2:5] | |
TestCopy<> t6 = {6}; //[CONSTR 2:6] | |
TestCopy<> t7 = 7; //[CONSTR 2:7] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t5.ts(); //5=============== | |
t1 = t3; //[OP=1] | |
t1.ts(); //1=============== | |
t1 = TestCopy<>{3}; //[CONSTR 2:3] | |
//[OP=3] | |
t3.ts(); //1=============== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vector<TestCopy<>> tm; | |
tm.push_back(TestCopy<>(99)); //[CONSTR 2:99] | |
//[MOVE] | |
tm[0].ts(); //99=============== |
OlderNewer