Core: 'Tuple' now synonym to 'MakeTuple'

git-svn-id: svn://ultimatepp.org/upp/trunk@7888 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-11-13 11:06:17 +00:00
parent 7e108dfb8f
commit 5a5ddb1e2d
2 changed files with 23 additions and 5 deletions

View file

@ -30,7 +30,7 @@ inline void AssertMoveable0(Tuple2<A, B> *)
}
template <typename A, typename B>
inline Tuple2<A, B> MakeTuple(const A& a, const B& b)
inline Tuple2<A, B> Tuple(const A& a, const B& b)
{
Tuple2<A, B> r;
r.a = a;
@ -38,6 +38,12 @@ inline Tuple2<A, B> MakeTuple(const A& a, const B& b)
return r;
}
template <typename A, typename B>
inline Tuple2<A, B> MakeTuple(const A& a, const B& b) // Old name
{
return Tuple(a, b);
}
template <typename A, typename B, typename C>
struct Tuple3 {
A a;
@ -72,7 +78,7 @@ inline void AssertMoveable0(Tuple3<A, B, C> *)
}
template <typename A, typename B, typename C>
inline Tuple3<A, B, C> MakeTuple(const A& a, const B& b, const C& c)
inline Tuple3<A, B, C> Tuple(const A& a, const B& b, const C& c)
{
Tuple3<A, B, C> r;
r.a = a;
@ -81,6 +87,12 @@ inline Tuple3<A, B, C> MakeTuple(const A& a, const B& b, const C& c)
return r;
}
template <typename A, typename B, typename C>
inline Tuple3<A, B, C> MakeTuple(const A& a, const B& b, const C& c)
{
return Tuple(a, b, c);
}
template <typename A, typename B, typename C, typename D>
struct Tuple4 {
A a;
@ -117,7 +129,7 @@ inline void AssertMoveable0(Tuple4<A, B, C, D> *)
}
template <typename A, typename B, typename C, typename D>
inline Tuple4<A, B, C, D> MakeTuple(const A& a, const B& b, const C& c, const D& d)
inline Tuple4<A, B, C, D> Tuple(const A& a, const B& b, const C& c, const D& d)
{
Tuple4<A, B, C, D> r;
r.a = a;
@ -127,6 +139,12 @@ inline Tuple4<A, B, C, D> MakeTuple(const A& a, const B& b, const C& c, const D&
return r;
}
template <typename A, typename B, typename C, typename D>
inline Tuple4<A, B, C, D> MakeTuple(const A& a, const B& b, const C& c, const D& d)
{
return Tuple(a, b, c, d);
}
template <typename T, typename U>
inline T *FindTuple(T *x, int n, const U& key) {
while(n--) {

View file

@ -636,10 +636,10 @@ equivalents to VectorMap/ArrayMap `- maps that keep keys sorted:&]
[s5; U`+`+ has template classes Tuple2, Tuple3 and Tuple4 for combining
2`-4 values with different types. These are quite similiar to
std`::tuple class, with some advantages.&]
[s5; To create a Tuple value, you can use MakeTuple function. If
[s5; To create a Tuple value, you can use the Tuple function. If
correct types canot be deduced from parameters, you can specify
them explicitly:&]
[s7; -|Tuple3<int, String, String> x `= [* MakeTuple]<int, String, String>(12,
[s7; -|Tuple3<int, String, String> x `= [* Tuple]<int, String, String>(12,
`"hello`", `"world`");&]
[s7; &]
[s5; Individual values are accessible as members a .. d:&]