libcxx initial import

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@103490 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant
2010-05-11 19:42:16 +00:00
commit bc8d3f97eb
3893 changed files with 1209942 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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... UTypes>
// explicit tuple(UTypes&&... u);
#include <tuple>
#include <cassert>
#include "../MoveOnly.h"
int main()
{
{
std::tuple<MoveOnly> t = MoveOnly(0);
}
}

View File

@@ -0,0 +1,55 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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... UTypes>
// explicit tuple(UTypes&&... u);
#include <tuple>
#include <cassert>
#include "../MoveOnly.h"
int main()
{
{
std::tuple<MoveOnly> t(MoveOnly(0));
assert(std::get<0>(t) == 0);
}
{
std::tuple<MoveOnly, MoveOnly> t(MoveOnly(0), MoveOnly(1));
assert(std::get<0>(t) == 0);
assert(std::get<1>(t) == 1);
}
{
std::tuple<MoveOnly, MoveOnly, MoveOnly> t(MoveOnly(0),
MoveOnly(1),
MoveOnly(2));
assert(std::get<0>(t) == 0);
assert(std::get<1>(t) == 1);
assert(std::get<2>(t) == 2);
}
// extensions
{
std::tuple<MoveOnly, MoveOnly, MoveOnly> t(MoveOnly(0),
MoveOnly(1));
assert(std::get<0>(t) == 0);
assert(std::get<1>(t) == 1);
assert(std::get<2>(t) == MoveOnly());
}
{
std::tuple<MoveOnly, MoveOnly, MoveOnly> t(MoveOnly(0));
assert(std::get<0>(t) == 0);
assert(std::get<1>(t) == MoveOnly());
assert(std::get<2>(t) == MoveOnly());
}
}

View File

@@ -0,0 +1,79 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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 Alloc>
// tuple(allocator_arg_t, const Alloc& a);
#include <tuple>
#include <cassert>
#include "../DefaultOnly.h"
#include "../allocators.h"
#include "../alloc_first.h"
#include "../alloc_last.h"
int main()
{
{
std::tuple<> t(std::allocator_arg, A1<int>());
}
{
std::tuple<int> t(std::allocator_arg, A1<int>());
assert(std::get<0>(t) == 0);
}
{
std::tuple<DefaultOnly> t(std::allocator_arg, A1<int>());
assert(std::get<0>(t) == DefaultOnly());
}
{
assert(!alloc_first::allocator_constructed);
std::tuple<alloc_first> t(std::allocator_arg, A1<int>(5));
assert(alloc_first::allocator_constructed);
assert(std::get<0>(t) == alloc_first());
}
{
assert(!alloc_last::allocator_constructed);
std::tuple<alloc_last> t(std::allocator_arg, A1<int>(5));
assert(alloc_last::allocator_constructed);
assert(std::get<0>(t) == alloc_last());
}
{
alloc_first::allocator_constructed = false;
std::tuple<DefaultOnly, alloc_first> t(std::allocator_arg, A1<int>(5));
assert(std::get<0>(t) == DefaultOnly());
assert(alloc_first::allocator_constructed);
assert(std::get<1>(t) == alloc_first());
}
{
alloc_first::allocator_constructed = false;
alloc_last::allocator_constructed = false;
std::tuple<DefaultOnly, alloc_first, alloc_last> t(std::allocator_arg,
A1<int>(5));
assert(std::get<0>(t) == DefaultOnly());
assert(alloc_first::allocator_constructed);
assert(std::get<1>(t) == alloc_first());
assert(alloc_last::allocator_constructed);
assert(std::get<2>(t) == alloc_last());
}
{
alloc_first::allocator_constructed = false;
alloc_last::allocator_constructed = false;
std::tuple<DefaultOnly, alloc_first, alloc_last> t(std::allocator_arg,
A2<int>(5));
assert(std::get<0>(t) == DefaultOnly());
assert(!alloc_first::allocator_constructed);
assert(std::get<1>(t) == alloc_first());
assert(!alloc_last::allocator_constructed);
assert(std::get<2>(t) == alloc_last());
}
}

View File

@@ -0,0 +1,71 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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 Alloc, class... UTypes>
// tuple(allocator_arg_t, const Alloc& a, UTypes&&...);
#include <tuple>
#include <cassert>
#include "../MoveOnly.h"
#include "../allocators.h"
#include "../alloc_first.h"
#include "../alloc_last.h"
int main()
{
{
std::tuple<MoveOnly> t(std::allocator_arg, A1<int>(), MoveOnly(0));
assert(std::get<0>(t) == 0);
}
{
std::tuple<MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(),
MoveOnly(0), MoveOnly(1));
assert(std::get<0>(t) == 0);
assert(std::get<1>(t) == 1);
}
{
std::tuple<MoveOnly, MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(),
MoveOnly(0),
1, 2);
assert(std::get<0>(t) == 0);
assert(std::get<1>(t) == 1);
assert(std::get<2>(t) == 2);
}
{
alloc_first::allocator_constructed = false;
alloc_last::allocator_constructed = false;
std::tuple<int, alloc_first, alloc_last> t(std::allocator_arg,
A1<int>(5), 1, 2, 3);
assert(std::get<0>(t) == 1);
assert(alloc_first::allocator_constructed);
assert(std::get<1>(t) == alloc_first(2));
assert(alloc_last::allocator_constructed);
assert(std::get<2>(t) == alloc_last(3));
}
// extensions
{
std::tuple<MoveOnly, MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(),
0, 1);
assert(std::get<0>(t) == 0);
assert(std::get<1>(t) == 1);
assert(std::get<2>(t) == MoveOnly());
}
{
std::tuple<MoveOnly, MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(),
0);
assert(std::get<0>(t) == 0);
assert(std::get<1>(t) == MoveOnly());
assert(std::get<2>(t) == MoveOnly());
}
}

View File

@@ -0,0 +1,74 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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 Alloc>
// tuple(allocator_arg_t, const Alloc& a, const Types&...);
#include <tuple>
#include <cassert>
#include "../allocators.h"
#include "../alloc_first.h"
#include "../alloc_last.h"
int main()
{
{
std::tuple<int> t(std::allocator_arg, A1<int>(), 3);
assert(std::get<0>(t) == 3);
}
{
assert(!alloc_first::allocator_constructed);
std::tuple<alloc_first> t(std::allocator_arg, A1<int>(5), alloc_first(3));
assert(alloc_first::allocator_constructed);
assert(std::get<0>(t) == alloc_first(3));
}
{
assert(!alloc_last::allocator_constructed);
std::tuple<alloc_last> t(std::allocator_arg, A1<int>(5), alloc_last(3));
assert(alloc_last::allocator_constructed);
assert(std::get<0>(t) == alloc_last(3));
}
{
alloc_first::allocator_constructed = false;
std::tuple<int, alloc_first> t(std::allocator_arg, A1<int>(5),
10, alloc_first(15));
assert(std::get<0>(t) == 10);
assert(alloc_first::allocator_constructed);
assert(std::get<1>(t) == alloc_first(15));
}
{
alloc_first::allocator_constructed = false;
alloc_last::allocator_constructed = false;
std::tuple<int, alloc_first, alloc_last> t(std::allocator_arg,
A1<int>(5), 1, alloc_first(2),
alloc_last(3));
assert(std::get<0>(t) == 1);
assert(alloc_first::allocator_constructed);
assert(std::get<1>(t) == alloc_first(2));
assert(alloc_last::allocator_constructed);
assert(std::get<2>(t) == alloc_last(3));
}
{
alloc_first::allocator_constructed = false;
alloc_last::allocator_constructed = false;
std::tuple<int, alloc_first, alloc_last> t(std::allocator_arg,
A2<int>(5), 1, alloc_first(2),
alloc_last(3));
assert(std::get<0>(t) == 1);
assert(!alloc_first::allocator_constructed);
assert(std::get<1>(t) == alloc_first(2));
assert(!alloc_last::allocator_constructed);
assert(std::get<2>(t) == alloc_last(3));
}
}

View File

@@ -0,0 +1,57 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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 Alloc, class U1, class U2>
// tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
#include <tuple>
#include <utility>
#include <cassert>
#include "../allocators.h"
#include "../alloc_first.h"
#include "../alloc_last.h"
int main()
{
{
typedef std::pair<double, int> T0;
typedef std::tuple<int, double> T1;
T0 t0(2, 3);
T1 t1(std::allocator_arg, A1<int>(5), t0);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == 3);
}
{
typedef std::pair<int, int> T0;
typedef std::tuple<alloc_first, double> T1;
T0 t0(2, 3);
alloc_first::allocator_constructed = false;
T1 t1(std::allocator_arg, A1<int>(5), t0);
assert(alloc_first::allocator_constructed);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == 3);
}
{
typedef std::pair<int, int> T0;
typedef std::tuple<alloc_first, alloc_last> T1;
T0 t0(2, 3);
alloc_first::allocator_constructed = false;
alloc_last::allocator_constructed = false;
T1 t1(std::allocator_arg, A1<int>(5), t0);
assert(alloc_first::allocator_constructed);
assert(alloc_last::allocator_constructed);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == 3);
}
}

View File

@@ -0,0 +1,67 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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 Alloc, class... UTypes>
// tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&);
#include <tuple>
#include <cassert>
#include "../allocators.h"
#include "../alloc_first.h"
#include "../alloc_last.h"
int main()
{
{
typedef std::tuple<double> T0;
typedef std::tuple<int> T1;
T0 t0(2.5);
T1 t1(std::allocator_arg, A1<int>(), t0);
assert(std::get<0>(t1) == 2);
}
{
typedef std::tuple<int> T0;
typedef std::tuple<alloc_first> T1;
T0 t0(2);
alloc_first::allocator_constructed = false;
T1 t1(std::allocator_arg, A1<int>(5), t0);
assert(alloc_first::allocator_constructed);
assert(std::get<0>(t1) == 2);
}
{
typedef std::tuple<int, int> T0;
typedef std::tuple<alloc_first, alloc_last> T1;
T0 t0(2, 3);
alloc_first::allocator_constructed = false;
alloc_last::allocator_constructed = false;
T1 t1(std::allocator_arg, A1<int>(5), t0);
assert(alloc_first::allocator_constructed);
assert(alloc_last::allocator_constructed);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == 3);
}
{
typedef std::tuple<double, int, int> T0;
typedef std::tuple<int, alloc_first, alloc_last> T1;
T0 t0(1.5, 2, 3);
alloc_first::allocator_constructed = false;
alloc_last::allocator_constructed = false;
T1 t1(std::allocator_arg, A1<int>(5), t0);
assert(alloc_first::allocator_constructed);
assert(alloc_last::allocator_constructed);
assert(std::get<0>(t1) == 1);
assert(std::get<1>(t1) == 2);
assert(std::get<2>(t1) == 3);
}
}

View File

@@ -0,0 +1,82 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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 Alloc, class... UTypes>
// tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...>&&);
#include <tuple>
#include <string>
#include <memory>
#include <cassert>
#include "../allocators.h"
#include "../alloc_first.h"
#include "../alloc_last.h"
struct B
{
int id_;
explicit B(int i) : id_(i) {}
virtual ~B() {}
};
struct D
: B
{
explicit D(int i) : B(i) {}
};
int main()
{
{
typedef std::tuple<int> T0;
typedef std::tuple<alloc_first> T1;
T0 t0(2);
alloc_first::allocator_constructed = false;
T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
assert(alloc_first::allocator_constructed);
assert(std::get<0>(t1) == 2);
}
{
typedef std::tuple<std::unique_ptr<D>> T0;
typedef std::tuple<std::unique_ptr<B>> T1;
T0 t0(std::unique_ptr<D>(new D(3)));
T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
assert(std::get<0>(t1)->id_ == 3);
}
{
typedef std::tuple<int, std::unique_ptr<D>> T0;
typedef std::tuple<alloc_first, std::unique_ptr<B>> T1;
T0 t0(2, std::unique_ptr<D>(new D(3)));
alloc_first::allocator_constructed = false;
T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
assert(alloc_first::allocator_constructed);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1)->id_ == 3);
}
{
typedef std::tuple<int, int, std::unique_ptr<D>> T0;
typedef std::tuple<alloc_last, alloc_first, std::unique_ptr<B>> T1;
T0 t0(1, 2, std::unique_ptr<D>(new D(3)));
alloc_first::allocator_constructed = false;
alloc_last::allocator_constructed = false;
T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
assert(alloc_first::allocator_constructed);
assert(alloc_last::allocator_constructed);
assert(std::get<0>(t1) == 1);
assert(std::get<1>(t1) == 2);
assert(std::get<2>(t1)->id_ == 3);
}
}

View File

@@ -0,0 +1,76 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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 Alloc>
// tuple(allocator_arg_t, const Alloc& a, const tuple&);
#include <tuple>
#include <cassert>
#include "../allocators.h"
#include "../alloc_first.h"
#include "../alloc_last.h"
int main()
{
{
typedef std::tuple<> T;
T t0;
T t(std::allocator_arg, A1<int>(), t0);
}
{
typedef std::tuple<int> T;
T t0(2);
T t(std::allocator_arg, A1<int>(), t0);
assert(std::get<0>(t) == 2);
}
{
typedef std::tuple<alloc_first> T;
T t0(2);
alloc_first::allocator_constructed = false;
T t(std::allocator_arg, A1<int>(5), t0);
assert(alloc_first::allocator_constructed);
assert(std::get<0>(t) == 2);
}
{
typedef std::tuple<alloc_last> T;
T t0(2);
alloc_last::allocator_constructed = false;
T t(std::allocator_arg, A1<int>(5), t0);
assert(alloc_last::allocator_constructed);
assert(std::get<0>(t) == 2);
}
{
typedef std::tuple<alloc_first, alloc_last> T;
T t0(2, 3);
alloc_first::allocator_constructed = false;
alloc_last::allocator_constructed = false;
T t(std::allocator_arg, A1<int>(5), t0);
assert(alloc_first::allocator_constructed);
assert(alloc_last::allocator_constructed);
assert(std::get<0>(t) == 2);
assert(std::get<1>(t) == 3);
}
{
typedef std::tuple<int, alloc_first, alloc_last> T;
T t0(1, 2, 3);
alloc_first::allocator_constructed = false;
alloc_last::allocator_constructed = false;
T t(std::allocator_arg, A1<int>(5), t0);
assert(alloc_first::allocator_constructed);
assert(alloc_last::allocator_constructed);
assert(std::get<0>(t) == 1);
assert(std::get<1>(t) == 2);
assert(std::get<2>(t) == 3);
}
}

View File

@@ -0,0 +1,75 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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 Alloc>
// tuple(allocator_arg_t, const Alloc& a, tuple&&);
#include <tuple>
#include <cassert>
#include "../MoveOnly.h"
#include "../allocators.h"
#include "../alloc_first.h"
#include "../alloc_last.h"
int main()
{
{
typedef std::tuple<> T;
T t0;
T t(std::allocator_arg, A1<int>(), std::move(t0));
}
{
typedef std::tuple<MoveOnly> T;
T t0(MoveOnly(0));
T t(std::allocator_arg, A1<int>(), std::move(t0));
assert(std::get<0>(t) == 0);
}
{
typedef std::tuple<alloc_first> T;
T t0(1);
alloc_first::allocator_constructed = false;
T t(std::allocator_arg, A1<int>(5), std::move(t0));
assert(alloc_first::allocator_constructed);
assert(std::get<0>(t) == 1);
}
{
typedef std::tuple<alloc_last> T;
T t0(1);
alloc_last::allocator_constructed = false;
T t(std::allocator_arg, A1<int>(5), std::move(t0));
assert(alloc_last::allocator_constructed);
assert(std::get<0>(t) == 1);
}
{
typedef std::tuple<MoveOnly, alloc_first> T;
T t0(0 ,1);
alloc_first::allocator_constructed = false;
T t(std::allocator_arg, A1<int>(5), std::move(t0));
assert(alloc_first::allocator_constructed);
assert(std::get<0>(t) == 0);
assert(std::get<1>(t) == 1);
}
{
typedef std::tuple<MoveOnly, alloc_first, alloc_last> T;
T t0(1, 2, 3);
alloc_first::allocator_constructed = false;
alloc_last::allocator_constructed = false;
T t(std::allocator_arg, A1<int>(5), std::move(t0));
assert(alloc_first::allocator_constructed);
assert(alloc_last::allocator_constructed);
assert(std::get<0>(t) == 1);
assert(std::get<1>(t) == 2);
assert(std::get<2>(t) == 3);
}
}

View File

@@ -0,0 +1,54 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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 Alloc, class U1, class U2>
// tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
#include <tuple>
#include <utility>
#include <memory>
#include <cassert>
#include "../allocators.h"
#include "../alloc_first.h"
#include "../alloc_last.h"
struct B
{
int id_;
explicit B(int i) : id_(i) {}
virtual ~B() {}
};
struct D
: B
{
explicit D(int i) : B(i) {}
};
int main()
{
{
typedef std::pair<int, std::unique_ptr<D>> T0;
typedef std::tuple<alloc_first, std::unique_ptr<B>> T1;
T0 t0(2, std::unique_ptr<D>(new D(3)));
alloc_first::allocator_constructed = false;
T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
assert(alloc_first::allocator_constructed);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1)->id_ == 3);
}
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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;
// explicit tuple(const T&...);
#include <tuple>
#include <string>
#include <cassert>
int main()
{
{
std::tuple<int> t = 2;
assert(std::get<0>(t) == 2);
}
}

View File

@@ -0,0 +1,62 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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;
// explicit tuple(const T&...);
#include <tuple>
#include <string>
#include <cassert>
int main()
{
{
std::tuple<int> t(2);
assert(std::get<0>(t) == 2);
}
{
std::tuple<int, char*> t(2, 0);
assert(std::get<0>(t) == 2);
assert(std::get<1>(t) == nullptr);
}
{
std::tuple<int, char*> t(2, nullptr);
assert(std::get<0>(t) == 2);
assert(std::get<1>(t) == nullptr);
}
{
std::tuple<int, char*, std::string> t(2, nullptr, "text");
assert(std::get<0>(t) == 2);
assert(std::get<1>(t) == nullptr);
assert(std::get<2>(t) == "text");
}
// extensions
{
std::tuple<int, char*, std::string> t(2);
assert(std::get<0>(t) == 2);
assert(std::get<1>(t) == nullptr);
assert(std::get<2>(t) == "");
}
{
std::tuple<int, char*, std::string> t(2, nullptr);
assert(std::get<0>(t) == 2);
assert(std::get<1>(t) == nullptr);
assert(std::get<2>(t) == "");
}
{
std::tuple<int, char*, std::string, double> t(2, nullptr, "text");
assert(std::get<0>(t) == 2);
assert(std::get<1>(t) == nullptr);
assert(std::get<2>(t) == "text");
assert(std::get<3>(t) == 0.0);
}
}

View File

@@ -0,0 +1,25 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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;
// explicit tuple(const T&...);
#include <tuple>
#include <string>
#include <cassert>
int main()
{
{
std::tuple<int, char*, std::string, double&> t(2, nullptr, "text");
}
}

View File

@@ -0,0 +1,30 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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 U1, class U2> tuple(const pair<U1, U2>& u);
#include <tuple>
#include <utility>
#include <cassert>
int main()
{
{
typedef std::pair<double, char> T0;
typedef std::tuple<int, short> T1;
T0 t0(2.5, 'a');
T1 t1 = t0;
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == short('a'));
}
}

View File

@@ -0,0 +1,70 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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... UTypes> tuple(const tuple<UTypes...>& u);
#include <tuple>
#include <string>
#include <cassert>
struct B
{
int id_;
explicit B(int i) : id_(i) {}
};
struct D
: B
{
explicit D(int i) : B(i) {}
};
int main()
{
{
typedef std::tuple<double> T0;
typedef std::tuple<int> T1;
T0 t0(2.5);
T1 t1 = t0;
assert(std::get<0>(t1) == 2);
}
{
typedef std::tuple<double, char> T0;
typedef std::tuple<int, int> T1;
T0 t0(2.5, 'a');
T1 t1 = t0;
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
}
{
typedef std::tuple<double, char, D> T0;
typedef std::tuple<int, int, B> T1;
T0 t0(2.5, 'a', D(3));
T1 t1 = t0;
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
assert(std::get<2>(t1).id_ == 3);
}
{
D d(3);
typedef std::tuple<double, char, D&> T0;
typedef std::tuple<int, int, B&> T1;
T0 t0(2.5, 'a', d);
T1 t1 = t0;
d.id_ = 2;
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
assert(std::get<2>(t1).id_ == 2);
}
}

View File

@@ -0,0 +1,82 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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... UTypes> tuple(tuple<UTypes...>&& u);
#include <tuple>
#include <string>
#include <memory>
#include <cassert>
struct B
{
int id_;
explicit B(int i) : id_(i) {}
virtual ~B() {}
};
struct D
: B
{
explicit D(int i) : B(i) {}
};
int main()
{
{
typedef std::tuple<double> T0;
typedef std::tuple<int> T1;
T0 t0(2.5);
T1 t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
}
{
typedef std::tuple<double, char> T0;
typedef std::tuple<int, int> T1;
T0 t0(2.5, 'a');
T1 t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
}
{
typedef std::tuple<double, char, D> T0;
typedef std::tuple<int, int, B> T1;
T0 t0(2.5, 'a', D(3));
T1 t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
assert(std::get<2>(t1).id_ == 3);
}
{
D d(3);
typedef std::tuple<double, char, D&> T0;
typedef std::tuple<int, int, B&> T1;
T0 t0(2.5, 'a', d);
T1 t1 = std::move(t0);
d.id_ = 2;
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
assert(std::get<2>(t1).id_ == 2);
}
{
typedef std::tuple<double, char, std::unique_ptr<D>> T0;
typedef std::tuple<int, int, std::unique_ptr<B>> T1;
T0 t0(2.5, 'a', std::unique_ptr<D>(new D(3)));
T1 t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
assert(std::get<2>(t1)->id_ == 3);
}
}

View File

@@ -0,0 +1,28 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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;
// tuple(const tuple& u) = default;
#include <tuple>
#include <cassert>
#include "../MoveOnly.h"
int main()
{
{
typedef std::tuple<MoveOnly> T;
T t0(MoveOnly(2));
T t = t0;
}
}

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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;
// tuple(const tuple& u) = default;
#include <tuple>
#include <string>
#include <cassert>
int main()
{
{
typedef std::tuple<> T;
T t0;
T t = t0;
}
{
typedef std::tuple<int> T;
T t0(2);
T t = t0;
assert(std::get<0>(t) == 2);
}
{
typedef std::tuple<int, char> T;
T t0(2, 'a');
T t = t0;
assert(std::get<0>(t) == 2);
assert(std::get<1>(t) == 'a');
}
{
typedef std::tuple<int, char, std::string> T;
T t0(2, 'a', "some text");
T t = t0;
assert(std::get<0>(t) == 2);
assert(std::get<1>(t) == 'a');
assert(std::get<2>(t) == "some text");
}
}

View File

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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;
// constexpr tuple();
#include <tuple>
#include <string>
#include <cassert>
#include "../DefaultOnly.h"
int main()
{
{
std::tuple<> t;
}
{
std::tuple<int> t;
assert(std::get<0>(t) == 0);
}
{
std::tuple<int, char*> t;
assert(std::get<0>(t) == 0);
assert(std::get<1>(t) == nullptr);
}
{
std::tuple<int, char*, std::string> t;
assert(std::get<0>(t) == 0);
assert(std::get<1>(t) == nullptr);
assert(std::get<2>(t) == "");
}
{
std::tuple<int, char*, std::string, DefaultOnly> t;
assert(std::get<0>(t) == 0);
assert(std::get<1>(t) == nullptr);
assert(std::get<2>(t) == "");
assert(std::get<3>(t) == DefaultOnly());
}
}

View File

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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;
// tuple(tuple&& u);
#include <tuple>
#include <cassert>
#include "../MoveOnly.h"
int main()
{
{
typedef std::tuple<> T;
T t0;
T t = std::move(t0);
}
{
typedef std::tuple<MoveOnly> T;
T t0(MoveOnly(0));
T t = std::move(t0);
assert(std::get<0>(t) == 0);
}
{
typedef std::tuple<MoveOnly, MoveOnly> T;
T t0(MoveOnly(0), MoveOnly(1));
T t = std::move(t0);
assert(std::get<0>(t) == 0);
assert(std::get<1>(t) == 1);
}
{
typedef std::tuple<MoveOnly, MoveOnly, MoveOnly> T;
T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2));
T t = std::move(t0);
assert(std::get<0>(t) == 0);
assert(std::get<1>(t) == 1);
assert(std::get<2>(t) == 2);
}
}

View File

@@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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 U1, class U2> tuple(pair<U1, U2>&& u);
#include <tuple>
#include <utility>
#include <memory>
#include <cassert>
struct B
{
int id_;
explicit B(int i) : id_(i) {}
virtual ~B() {}
};
struct D
: B
{
explicit D(int i) : B(i) {}
};
int main()
{
{
typedef std::pair<double, std::unique_ptr<D>> T0;
typedef std::tuple<int, std::unique_ptr<B>> T1;
T0 t0(2.5, std::unique_ptr<D>(new D(3)));
T1 t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1)->id_ == 3);
}
}