cxx/test/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp
Howard Hinnant bc8d3f97eb libcxx initial import
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@103490 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-11 19:42:16 +00:00

116 lines
3.6 KiB
C++

//===----------------------------------------------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <tuple>
// template <class... Types> class tuple;
// template <class... TTypes, class... UTypes>
// tuple<TTypes..., UTypes...>
// tuple_cat(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
//
// template <class... TTypes, class... UTypes>
// tuple<TTypes..., UTypes...>
// tuple_cat(const tuple<TTypes...>&& t, const tuple<UTypes...>& u);
//
// template <class... TTypes, class... UTypes>
// tuple<TTypes..., UTypes...>
// tuple_cat(const tuple<TTypes...>& t, const tuple<UTypes...>&& u);
//
// template <class... TTypes, class... UTypes>
// tuple<TTypes..., UTypes...>
// tuple_cat(const tuple<TTypes...>&& t, const tuple<UTypes...>&& u);
#include <tuple>
#include <string>
#include <cassert>
#include "../MoveOnly.h"
int main()
{
{
std::tuple<> t1;
std::tuple<> t2;
std::tuple<> t3 = std::tuple_cat(t1, t2);
}
{
std::tuple<> t1;
std::tuple<int> t2(2);
std::tuple<int> t3 = std::tuple_cat(t1, t2);
assert(std::get<0>(t3) == 2);
}
{
std::tuple<> t1;
std::tuple<int> t2(2);
std::tuple<int> t3 = std::tuple_cat(t2, t1);
assert(std::get<0>(t3) == 2);
}
{
std::tuple<int*> t1;
std::tuple<int> t2(2);
std::tuple<int*, int> t3 = std::tuple_cat(t1, t2);
assert(std::get<0>(t3) == nullptr);
assert(std::get<1>(t3) == 2);
}
{
std::tuple<int*> t1;
std::tuple<int> t2(2);
std::tuple<int, int*> t3 = std::tuple_cat(t2, t1);
assert(std::get<0>(t3) == 2);
assert(std::get<1>(t3) == nullptr);
}
{
std::tuple<int*> t1;
std::tuple<int, double> t2(2, 3.5);
std::tuple<int*, int, double> t3 = std::tuple_cat(t1, t2);
assert(std::get<0>(t3) == nullptr);
assert(std::get<1>(t3) == 2);
assert(std::get<2>(t3) == 3.5);
}
{
std::tuple<int*> t1;
std::tuple<int, double> t2(2, 3.5);
std::tuple<int, double, int*> t3 = std::tuple_cat(t2, t1);
assert(std::get<0>(t3) == 2);
assert(std::get<1>(t3) == 3.5);
assert(std::get<2>(t3) == nullptr);
}
{
std::tuple<int*, MoveOnly> t1(nullptr, 1);
std::tuple<int, double> t2(2, 3.5);
std::tuple<int*, MoveOnly, int, double> t3 =
std::tuple_cat(std::move(t1), t2);
assert(std::get<0>(t3) == nullptr);
assert(std::get<1>(t3) == 1);
assert(std::get<2>(t3) == 2);
assert(std::get<3>(t3) == 3.5);
}
{
std::tuple<int*, MoveOnly> t1(nullptr, 1);
std::tuple<int, double> t2(2, 3.5);
std::tuple<int, double, int*, MoveOnly> t3 =
std::tuple_cat(t2, std::move(t1));
assert(std::get<0>(t3) == 2);
assert(std::get<1>(t3) == 3.5);
assert(std::get<2>(t3) == nullptr);
assert(std::get<3>(t3) == 1);
}
{
std::tuple<MoveOnly, MoveOnly> t1(1, 2);
std::tuple<int*, MoveOnly> t2(nullptr, 4);
std::tuple<MoveOnly, MoveOnly, int*, MoveOnly> t3 =
std::tuple_cat(std::move(t1), std::move(t2));
assert(std::get<0>(t3) == 1);
assert(std::get<1>(t3) == 2);
assert(std::get<2>(t3) == nullptr);
assert(std::get<3>(t3) == 4);
}
}