C++/Library
2021. 3. 12. 17:25
tuple
C++11
<tuple>
라이브러리#include <iostream> #include <tuple> std::tuple<int, double> getTuple() { return (std::make_tuple(10, 3.14)); } int main() { using namespace std; tuple<int, double> my_tp = getTuple(); cout << get<0>(my_tp) << endl; cout << get<1>(my_tp) << endl; } /* stdout stderr 10 3.14 */
C++17
다음과 같이 작성 가능
#include <iostream> #include <tuple> std::tuple<int, double> getTuple() { return (std::make_tuple(10, 3.14)); } int main() { using namespace std; auto [a, d] = getTuple(); cout << a << endl; // 10 cout << d << endl; // 3.14 } /* stdout stderr 10 3.14 */
'C++ > Library' 카테고리의 다른 글
C++ assert (0) | 2021.03.12 |
---|---|
C++ vector (0) | 2021.03.12 |
C++ array (0) | 2021.03.11 |
C++ typeinfo (0) | 2021.03.11 |
C++ cin.ignore (0) | 2021.03.11 |