SlideShare a Scribd company logo
std::tuple
tuple 이란?
2개 이상의 값을 하나의 변수로 묶을 수 있게 해주는 library
std::tuple<int, float, std::string> t1
= std::tuple<int, float, std::string>( 1, 3.0f, "tuple" );
어떻게 만드나?
선언 후 var()에 바로 값을 대입하거나
std::tuple<int, float, std::string> t1( 1, 3.0f, "tuple is good" );
선언과 동일한 tuple형을 만들어서 대입하거나,(아래 코드)
make_tuple로 알아서 값을 만들어 넣거나 할 수 있음
std::make_tuple( 1, 3.0f,"tuple is good" );
어떻게 만드나?
auto 도 사용가능,
심지어는 auto 와 make_tuple로 아래 t4 같은 변태조합도 가능함.
(자료형이 어떻게 될 지 모르니 저렇게는 안쓰는게 좋을 듯...)
어떻게 쓰나?
std::get<#>(var) 식으로 선언된 자료의 순서를 이용해 꺼내올 수 있다.
자료 수정 역시 std::get<#>(var) = var2 식으로 할 수 있다.
tuple에 원소가 몇 개 있는지는 어떻게?
std::tuple_size<decltype(var)>::value 로 구할 수 있다.
반환 값은 unsigned 이다.
그 외..
참조 데이터를 가지는 tuple을 만들려면
std::tie(var1, var2 .. ) 를 사용한다.
그 외..
tuple을 변수들에 한 번에 담으려면
std::tie(var1, var2 .. ) 를 거꾸로 사용한다.
그 외..
tuple들을 합치려면 std::tuple_cat(tuple1, tuple2)을 사용한다.

More Related Content

PDF
[Swift] Tuple
PPTX
이펙티브 C++ 789 공부
PPTX
파이썬 숫자,변수,문자열
PDF
2.linear regression and logistic regression
PDF
4.representing data and engineering features
PPTX
2.supervised learning(epoch#2)-1
PPTX
2.supervised learning(epoch#2)-3
PDF
Python basic grammer
[Swift] Tuple
이펙티브 C++ 789 공부
파이썬 숫자,변수,문자열
2.linear regression and logistic regression
4.representing data and engineering features
2.supervised learning(epoch#2)-1
2.supervised learning(epoch#2)-3
Python basic grammer

What's hot (8)

PPTX
[GPG 스터디] 1.4 게임프로그래밍에서의 STL 활용
PDF
6.algorithm chains and piplines(epoch#2)
PPTX
2.supervised learning(epoch#2)-2
PDF
2015 Kitel C 언어 강좌3
PDF
7.woring with text data(epoch#2)
PDF
PINTOS Operating system homework 2
PPTX
Swift 튜플 (tuples)
PDF
Stl vector, list, map
[GPG 스터디] 1.4 게임프로그래밍에서의 STL 활용
6.algorithm chains and piplines(epoch#2)
2.supervised learning(epoch#2)-2
2015 Kitel C 언어 강좌3
7.woring with text data(epoch#2)
PINTOS Operating system homework 2
Swift 튜플 (tuples)
Stl vector, list, map
Ad

Similar to C++11 Tuple (9)

PPTX
Std bind
PDF
STL study (skyLab)
PDF
Haskell study 2
PDF
프로그래밍 대회: C++11 이야기
PPTX
C++11
PDF
2 swift 상수,변수,튜풀 옵셔널
PDF
05_STL컨테이너정리
PPTX
amugona study 1회
Std bind
STL study (skyLab)
Haskell study 2
프로그래밍 대회: C++11 이야기
C++11
2 swift 상수,변수,튜풀 옵셔널
05_STL컨테이너정리
amugona study 1회
Ad

More from quxn6 (12)

PPTX
모어이펙티브 C++ 5,6
PPTX
모어 이펙티브 c++ 5장 스터디
PPTX
모어이펙티브 C++ 3,4장 예외, 효율 스터디
PPTX
모어 이펙티브 c++ 1,2장 스터디
PPTX
이펙티브 C++ 5,6 장 스터디
PPTX
비실사렌더링-툰 쉐이딩
PPTX
이펙티브 C++ 공부
PPTX
중급 소켓프로그래밍
PPTX
이펙티브 C++ 스터디
PPTX
입체충돌처리
PPTX
introduce unity3D and playmaker basic
PPTX
TCP echo 서버 및 클라이언트 예제 스터디
모어이펙티브 C++ 5,6
모어 이펙티브 c++ 5장 스터디
모어이펙티브 C++ 3,4장 예외, 효율 스터디
모어 이펙티브 c++ 1,2장 스터디
이펙티브 C++ 5,6 장 스터디
비실사렌더링-툰 쉐이딩
이펙티브 C++ 공부
중급 소켓프로그래밍
이펙티브 C++ 스터디
입체충돌처리
introduce unity3D and playmaker basic
TCP echo 서버 및 클라이언트 예제 스터디

C++11 Tuple

  • 2. tuple 이란? 2개 이상의 값을 하나의 변수로 묶을 수 있게 해주는 library std::tuple<int, float, std::string> t1 = std::tuple<int, float, std::string>( 1, 3.0f, "tuple" );
  • 3. 어떻게 만드나? 선언 후 var()에 바로 값을 대입하거나 std::tuple<int, float, std::string> t1( 1, 3.0f, "tuple is good" ); 선언과 동일한 tuple형을 만들어서 대입하거나,(아래 코드) make_tuple로 알아서 값을 만들어 넣거나 할 수 있음 std::make_tuple( 1, 3.0f,"tuple is good" );
  • 4. 어떻게 만드나? auto 도 사용가능, 심지어는 auto 와 make_tuple로 아래 t4 같은 변태조합도 가능함. (자료형이 어떻게 될 지 모르니 저렇게는 안쓰는게 좋을 듯...)
  • 5. 어떻게 쓰나? std::get<#>(var) 식으로 선언된 자료의 순서를 이용해 꺼내올 수 있다. 자료 수정 역시 std::get<#>(var) = var2 식으로 할 수 있다.
  • 6. tuple에 원소가 몇 개 있는지는 어떻게? std::tuple_size<decltype(var)>::value 로 구할 수 있다. 반환 값은 unsigned 이다.
  • 7. 그 외.. 참조 데이터를 가지는 tuple을 만들려면 std::tie(var1, var2 .. ) 를 사용한다.
  • 8. 그 외.. tuple을 변수들에 한 번에 담으려면 std::tie(var1, var2 .. ) 를 거꾸로 사용한다.
  • 9. 그 외.. tuple들을 합치려면 std::tuple_cat(tuple1, tuple2)을 사용한다.