Provide a shorter syntax for creating tuples [closes #28]
This commit is contained in:
parent
e5c50e115e
commit
c1ac1df7dc
|
@ -702,12 +702,14 @@ $(1,2)$, $(1,5)$ and $(2,3)$.
|
||||||
|
|
||||||
In a similar way, tuples (\texttt{tuple})
|
In a similar way, tuples (\texttt{tuple})
|
||||||
are sorted primarily by the first element,
|
are sorted primarily by the first element,
|
||||||
secondarily by the second element, etc.:
|
secondarily by the second element, etc.\footnote{Note that in some older compilers,
|
||||||
|
the function \texttt{make\_tuple} has to be used to create a tuple instead of
|
||||||
|
braces (for example, \texttt{make\_tuple(2,1,4)} instead of \texttt{\{2,1,4\}}).}:
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
vector<tuple<int,int,int>> v;
|
vector<tuple<int,int,int>> v;
|
||||||
v.push_back(make_tuple(2,1,4));
|
v.push_back({2,1,4});
|
||||||
v.push_back(make_tuple(1,5,3));
|
v.push_back({1,5,3});
|
||||||
v.push_back(make_tuple(2,1,3));
|
v.push_back({2,1,3});
|
||||||
sort(v.begin(), v.end());
|
sort(v.begin(), v.end());
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
After this, the order of the tuples is
|
After this, the order of the tuples is
|
||||||
|
|
Loading…
Reference in New Issue