Member-only story

Sugar Notes for C++11 (1): Tuple

Yi-Hsiang Kao
2 min readSep 17, 2017

--

I’ve switched to use C++ as primary programming language to practice algorithm problems for a while. The language still evolves these days as new standard C++14 and C++17 coming out. There’s a lot of new features and useful tools make C++11 more modern and looks like a new language compared to its old ancestor C or C++03.

I would continue to update the notes on what features I have used, for both a cheat sheet to review and a note to share, where anybody could also take a look and to see if there’s a more modern or efficient new method in C++.

C++11 Tuple

1. Usage (Text from <tuple>)

Tuples are objects that pack elements of (possibly) different types together in a single object, generalized for any number of elements.

Conceptually, they are similar to plain old data structures (C-like structs) but instead of having named data members, its elements are accessed by their order in the tuple.

Just similar to Tuple in Python — — An ordered collection of different data

2. Example

You have to include <tuple>.

--

--

Yi-Hsiang Kao
Yi-Hsiang Kao

Written by Yi-Hsiang Kao

Risk@Uber 沒事多寫字,多寫字沒事

No responses yet