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:
12
test/utilities/tuple/tuple.general/nothing_to_do.pass.cpp
Normal file
12
test/utilities/tuple/tuple.general/nothing_to_do.pass.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
26
test/utilities/tuple/tuple.tuple/DefaultOnly.h
Normal file
26
test/utilities/tuple/tuple.tuple/DefaultOnly.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef DEFAULTONLY_H
|
||||
#define DEFAULTONLY_H
|
||||
|
||||
#include <cassert>
|
||||
|
||||
class DefaultOnly
|
||||
{
|
||||
int data_;
|
||||
|
||||
DefaultOnly(const DefaultOnly&);
|
||||
DefaultOnly& operator=(const DefaultOnly&);
|
||||
public:
|
||||
static int count;
|
||||
|
||||
DefaultOnly() : data_(-1) {++count;}
|
||||
~DefaultOnly() {data_ = 0; --count;}
|
||||
|
||||
friend bool operator==(const DefaultOnly& x, const DefaultOnly& y)
|
||||
{return x.data_ == y.data_;}
|
||||
friend bool operator< (const DefaultOnly& x, const DefaultOnly& y)
|
||||
{return x.data_ < y.data_;}
|
||||
};
|
||||
|
||||
int DefaultOnly::count = 0;
|
||||
|
||||
#endif
|
41
test/utilities/tuple/tuple.tuple/MoveOnly.h
Normal file
41
test/utilities/tuple/tuple.tuple/MoveOnly.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef MOVEONLY_H
|
||||
#define MOVEONLY_H
|
||||
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
|
||||
class MoveOnly
|
||||
{
|
||||
MoveOnly(const MoveOnly&);
|
||||
MoveOnly& operator=(const MoveOnly&);
|
||||
|
||||
int data_;
|
||||
public:
|
||||
MoveOnly(int data = 1) : data_(data) {}
|
||||
MoveOnly(MoveOnly&& x)
|
||||
: data_(x.data_) {x.data_ = 0;}
|
||||
MoveOnly& operator=(MoveOnly&& x)
|
||||
{data_ = x.data_; x.data_ = 0; return *this;}
|
||||
|
||||
int get() const {return data_;}
|
||||
|
||||
bool operator==(const MoveOnly& x) const {return data_ == x.data_;}
|
||||
bool operator< (const MoveOnly& x) const {return data_ < x.data_;}
|
||||
};
|
||||
|
||||
namespace std {
|
||||
|
||||
template <>
|
||||
struct hash<MoveOnly>
|
||||
: public std::unary_function<MoveOnly, std::size_t>
|
||||
{
|
||||
std::size_t operator()(const MoveOnly& x) const {return x.get();}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
49
test/utilities/tuple/tuple.tuple/alloc_first.h
Normal file
49
test/utilities/tuple/tuple.tuple/alloc_first.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#ifndef ALLOC_FIRST_H
|
||||
#define ALLOC_FIRST_H
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "allocators.h"
|
||||
|
||||
struct alloc_first
|
||||
{
|
||||
static bool allocator_constructed;
|
||||
|
||||
typedef A1<int> allocator_type;
|
||||
|
||||
int data_;
|
||||
|
||||
alloc_first() : data_(0) {}
|
||||
alloc_first(int d) : data_(d) {}
|
||||
alloc_first(std::allocator_arg_t, const A1<int>& a)
|
||||
: data_(0)
|
||||
{
|
||||
assert(a.id() == 5);
|
||||
allocator_constructed = true;
|
||||
}
|
||||
|
||||
alloc_first(std::allocator_arg_t, const A1<int>& a, int d)
|
||||
: data_(d)
|
||||
{
|
||||
assert(a.id() == 5);
|
||||
allocator_constructed = true;
|
||||
}
|
||||
|
||||
alloc_first(std::allocator_arg_t, const A1<int>& a, const alloc_first& d)
|
||||
: data_(d.data_)
|
||||
{
|
||||
assert(a.id() == 5);
|
||||
allocator_constructed = true;
|
||||
}
|
||||
|
||||
~alloc_first() {data_ = -1;}
|
||||
|
||||
friend bool operator==(const alloc_first& x, const alloc_first& y)
|
||||
{return x.data_ == y.data_;}
|
||||
friend bool operator< (const alloc_first& x, const alloc_first& y)
|
||||
{return x.data_ < y.data_;}
|
||||
};
|
||||
|
||||
bool alloc_first::allocator_constructed = false;
|
||||
|
||||
#endif
|
49
test/utilities/tuple/tuple.tuple/alloc_last.h
Normal file
49
test/utilities/tuple/tuple.tuple/alloc_last.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#ifndef ALLOC_LAST_H
|
||||
#define ALLOC_LAST_H
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "allocators.h"
|
||||
|
||||
struct alloc_last
|
||||
{
|
||||
static bool allocator_constructed;
|
||||
|
||||
typedef A1<int> allocator_type;
|
||||
|
||||
int data_;
|
||||
|
||||
alloc_last() : data_(0) {}
|
||||
alloc_last(int d) : data_(d) {}
|
||||
alloc_last(const A1<int>& a)
|
||||
: data_(0)
|
||||
{
|
||||
assert(a.id() == 5);
|
||||
allocator_constructed = true;
|
||||
}
|
||||
|
||||
alloc_last(int d, const A1<int>& a)
|
||||
: data_(d)
|
||||
{
|
||||
assert(a.id() == 5);
|
||||
allocator_constructed = true;
|
||||
}
|
||||
|
||||
alloc_last(const alloc_last& d, const A1<int>& a)
|
||||
: data_(d.data_)
|
||||
{
|
||||
assert(a.id() == 5);
|
||||
allocator_constructed = true;
|
||||
}
|
||||
|
||||
~alloc_last() {data_ = -1;}
|
||||
|
||||
friend bool operator==(const alloc_last& x, const alloc_last& y)
|
||||
{return x.data_ == y.data_;}
|
||||
friend bool operator< (const alloc_last& x, const alloc_last& y)
|
||||
{return x.data_ < y.data_;}
|
||||
};
|
||||
|
||||
bool alloc_last::allocator_constructed = false;
|
||||
|
||||
#endif
|
176
test/utilities/tuple/tuple.tuple/allocators.h
Normal file
176
test/utilities/tuple/tuple.tuple/allocators.h
Normal file
@@ -0,0 +1,176 @@
|
||||
#ifndef ALLOCATORS_H
|
||||
#define ALLOCATORS_H
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
template <class T>
|
||||
class A1
|
||||
{
|
||||
int id_;
|
||||
public:
|
||||
explicit A1(int id = 0) : id_(id) {}
|
||||
|
||||
typedef T value_type;
|
||||
|
||||
int id() const {return id_;}
|
||||
|
||||
static bool copy_called;
|
||||
static bool move_called;
|
||||
static bool allocate_called;
|
||||
static std::pair<T*, std::size_t> deallocate_called;
|
||||
|
||||
A1(const A1& a) : id_(a.id()) {copy_called = true;}
|
||||
A1(A1&& a) : id_(a.id()) {move_called = true;}
|
||||
|
||||
template <class U>
|
||||
A1(const A1<U>& a) : id_(a.id()) {copy_called = true;}
|
||||
template <class U>
|
||||
A1(A1<U>&& a) : id_(a.id()) {move_called = true;}
|
||||
|
||||
T* allocate(std::size_t n)
|
||||
{
|
||||
allocate_called = true;
|
||||
return (T*)n;
|
||||
}
|
||||
|
||||
void deallocate(T* p, std::size_t n)
|
||||
{
|
||||
deallocate_called = std::pair<T*, std::size_t>(p, n);
|
||||
}
|
||||
|
||||
std::size_t max_size() const {return id_;}
|
||||
};
|
||||
|
||||
template <class T> bool A1<T>::copy_called = false;
|
||||
template <class T> bool A1<T>::move_called = false;
|
||||
template <class T> bool A1<T>::allocate_called = false;
|
||||
template <class T> std::pair<T*, std::size_t> A1<T>::deallocate_called;
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
bool operator==(const A1<T>& x, const A1<U>& y)
|
||||
{
|
||||
return x.id() == y.id();
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
bool operator!=(const A1<T>& x, const A1<U>& y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
class A2
|
||||
{
|
||||
int id_;
|
||||
public:
|
||||
explicit A2(int id = 0) : id_(id) {}
|
||||
|
||||
typedef T value_type;
|
||||
|
||||
typedef unsigned size_type;
|
||||
typedef int difference_type;
|
||||
|
||||
typedef std::true_type propagate_on_container_move_assignment;
|
||||
|
||||
int id() const {return id_;}
|
||||
|
||||
static bool copy_called;
|
||||
static bool move_called;
|
||||
static bool allocate_called;
|
||||
|
||||
A2(const A2& a) : id_(a.id()) {copy_called = true;}
|
||||
A2(A2&& a) : id_(a.id()) {move_called = true;}
|
||||
|
||||
T* allocate(std::size_t n, const void* hint)
|
||||
{
|
||||
allocate_called = true;
|
||||
return (T*)hint;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> bool A2<T>::copy_called = false;
|
||||
template <class T> bool A2<T>::move_called = false;
|
||||
template <class T> bool A2<T>::allocate_called = false;
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
bool operator==(const A2<T>& x, const A2<U>& y)
|
||||
{
|
||||
return x.id() == y.id();
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
bool operator!=(const A2<T>& x, const A2<U>& y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
class A3
|
||||
{
|
||||
int id_;
|
||||
public:
|
||||
explicit A3(int id = 0) : id_(id) {}
|
||||
|
||||
typedef T value_type;
|
||||
|
||||
typedef std::true_type propagate_on_container_copy_assignment;
|
||||
typedef std::true_type propagate_on_container_swap;
|
||||
|
||||
int id() const {return id_;}
|
||||
|
||||
static bool copy_called;
|
||||
static bool move_called;
|
||||
static bool constructed;
|
||||
static bool destroy_called;
|
||||
|
||||
A3(const A3& a) : id_(a.id()) {copy_called = true;}
|
||||
A3(A3&& a) : id_(a.id()) {move_called = true;}
|
||||
|
||||
template <class U, class ...Args>
|
||||
void construct(U* p, Args&& ...args)
|
||||
{
|
||||
::new (p) U(std::forward<Args>(args)...);
|
||||
constructed = true;
|
||||
}
|
||||
|
||||
template <class U>
|
||||
void destroy(U* p)
|
||||
{
|
||||
p->~U();
|
||||
destroy_called = true;
|
||||
}
|
||||
|
||||
A3 select_on_container_copy_construction() const {return A3(-1);}
|
||||
};
|
||||
|
||||
|
||||
|
||||
template <class T> bool A3<T>::copy_called = false;
|
||||
template <class T> bool A3<T>::move_called = false;
|
||||
template <class T> bool A3<T>::constructed = false;
|
||||
template <class T> bool A3<T>::destroy_called = false;
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
bool operator==(const A3<T>& x, const A3<U>& y)
|
||||
{
|
||||
return x.id() == y.id();
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
bool operator!=(const A3<T>& x, const A3<U>& y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
44
test/utilities/tuple/tuple.tuple/empty_member.pass.cpp
Normal file
44
test/utilities/tuple/tuple.tuple/empty_member.pass.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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;
|
||||
|
||||
// This is not a portable test
|
||||
|
||||
#include <tuple>
|
||||
|
||||
struct A {};
|
||||
|
||||
struct B {};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::tuple<int, A> T;
|
||||
static_assert((sizeof(T) == sizeof(int)), "");
|
||||
}
|
||||
{
|
||||
typedef std::tuple<A, int> T;
|
||||
static_assert((sizeof(T) == sizeof(int)), "");
|
||||
}
|
||||
{
|
||||
typedef std::tuple<A, int, B> T;
|
||||
static_assert((sizeof(T) == sizeof(int)), "");
|
||||
}
|
||||
{
|
||||
typedef std::tuple<A, B, int> T;
|
||||
static_assert((sizeof(T) == sizeof(int)), "");
|
||||
}
|
||||
{
|
||||
typedef std::tuple<int, A, B> T;
|
||||
static_assert((sizeof(T) == sizeof(int)), "");
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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& operator=(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;
|
||||
t1 = t0;
|
||||
assert(std::get<0>(t1) == 2);
|
||||
assert(std::get<1>(t1) == short('a'));
|
||||
}
|
||||
}
|
@@ -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... UTypes>
|
||||
// tuple& operator=(const tuple<UTypes...>& u);
|
||||
|
||||
#include <tuple>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
struct B
|
||||
{
|
||||
int id_;
|
||||
|
||||
explicit B(int i = 0) : id_(i) {}
|
||||
};
|
||||
|
||||
struct D
|
||||
: B
|
||||
{
|
||||
explicit D(int i = 0) : B(i) {}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::tuple<double> T0;
|
||||
typedef std::tuple<int> T1;
|
||||
T0 t0(2.5);
|
||||
T1 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;
|
||||
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;
|
||||
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);
|
||||
D d2(2);
|
||||
typedef std::tuple<double, char, D&> T0;
|
||||
typedef std::tuple<int, int, B&> T1;
|
||||
T0 t0(2.5, 'a', d2);
|
||||
T1 t1(1.5, 'b', d);
|
||||
t1 = t0;
|
||||
assert(std::get<0>(t1) == 2);
|
||||
assert(std::get<1>(t1) == int('a'));
|
||||
assert(std::get<2>(t1).id_ == 2);
|
||||
}
|
||||
}
|
@@ -0,0 +1,88 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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& operator=(tuple<UTypes...>&& u);
|
||||
|
||||
#include <tuple>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
struct B
|
||||
{
|
||||
int id_;
|
||||
|
||||
explicit B(int i= 0) : 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;
|
||||
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;
|
||||
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;
|
||||
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);
|
||||
D d2(2);
|
||||
typedef std::tuple<double, char, D&> T0;
|
||||
typedef std::tuple<int, int, B&> T1;
|
||||
T0 t0(2.5, 'a', d2);
|
||||
T1 t1(1.5, 'b', d);
|
||||
t1 = std::move(t0);
|
||||
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;
|
||||
t1 = std::move(t0);
|
||||
assert(std::get<0>(t1) == 2);
|
||||
assert(std::get<1>(t1) == int('a'));
|
||||
assert(std::get<2>(t1)->id_ == 3);
|
||||
}
|
||||
}
|
29
test/utilities/tuple/tuple.tuple/tuple.assign/copy.fail.cpp
Normal file
29
test/utilities/tuple/tuple.tuple/tuple.assign/copy.fail.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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& operator=(const tuple& u);
|
||||
|
||||
#include <tuple>
|
||||
#include <cassert>
|
||||
|
||||
#include "../MoveOnly.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::tuple<MoveOnly> T;
|
||||
T t0(MoveOnly(2));
|
||||
T t;
|
||||
t = t0;
|
||||
}
|
||||
}
|
52
test/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp
Normal file
52
test/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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& operator=(const tuple& u);
|
||||
|
||||
#include <tuple>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::tuple<> T;
|
||||
T t0;
|
||||
T t;
|
||||
t = t0;
|
||||
}
|
||||
{
|
||||
typedef std::tuple<int> T;
|
||||
T t0(2);
|
||||
T t;
|
||||
t = t0;
|
||||
assert(std::get<0>(t) == 2);
|
||||
}
|
||||
{
|
||||
typedef std::tuple<int, char> T;
|
||||
T t0(2, 'a');
|
||||
T 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;
|
||||
t = t0;
|
||||
assert(std::get<0>(t) == 2);
|
||||
assert(std::get<1>(t) == 'a');
|
||||
assert(std::get<2>(t) == "some text");
|
||||
}
|
||||
}
|
53
test/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp
Normal file
53
test/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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& operator=(tuple&& u);
|
||||
|
||||
#include <tuple>
|
||||
#include <cassert>
|
||||
|
||||
#include "../MoveOnly.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::tuple<> T;
|
||||
T t0;
|
||||
T t;
|
||||
t = std::move(t0);
|
||||
}
|
||||
{
|
||||
typedef std::tuple<MoveOnly> T;
|
||||
T t0(MoveOnly(0));
|
||||
T 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;
|
||||
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;
|
||||
t = std::move(t0);
|
||||
assert(std::get<0>(t) == 0);
|
||||
assert(std::get<1>(t) == 1);
|
||||
assert(std::get<2>(t) == 2);
|
||||
}
|
||||
}
|
@@ -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;
|
||||
|
||||
// template <class U1, class U2>
|
||||
// tuple& operator=(pair<U1, U2>&& u);
|
||||
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
struct B
|
||||
{
|
||||
int id_;
|
||||
|
||||
explicit B(int i = 0) : 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;
|
||||
t1 = std::move(t0);
|
||||
assert(std::get<0>(t1) == 2);
|
||||
assert(std::get<1>(t1)->id_ == 3);
|
||||
}
|
||||
}
|
27
test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.fail.cpp
Normal file
27
test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.fail.cpp
Normal 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);
|
||||
}
|
||||
}
|
55
test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp
Normal file
55
test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp
Normal 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());
|
||||
}
|
||||
}
|
79
test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp
Normal file
79
test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp
Normal 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());
|
||||
}
|
||||
}
|
@@ -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());
|
||||
}
|
||||
}
|
@@ -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));
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -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");
|
||||
}
|
||||
}
|
@@ -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'));
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
28
test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.fail.cpp
Normal file
28
test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.fail.cpp
Normal 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;
|
||||
}
|
||||
}
|
48
test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.pass.cpp
Normal file
48
test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.pass.cpp
Normal 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");
|
||||
}
|
||||
}
|
@@ -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());
|
||||
}
|
||||
}
|
49
test/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp
Normal file
49
test/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp
Normal 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);
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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... Types>
|
||||
// tuple<VTypes...> make_tuple(Types&&... t);
|
||||
|
||||
#include <tuple>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int i = 0;
|
||||
float j = 0;
|
||||
std::tuple<int, int&, float&> t = std::make_tuple(1, std::ref(i),
|
||||
std::ref(j));
|
||||
assert(std::get<0>(t) == 1);
|
||||
assert(std::get<1>(t) == 0);
|
||||
assert(std::get<2>(t) == 0);
|
||||
i = 2;
|
||||
j = 3.5;
|
||||
assert(std::get<0>(t) == 1);
|
||||
assert(std::get<1>(t) == 2);
|
||||
assert(std::get<2>(t) == 3.5);
|
||||
std::get<1>(t) = 0;
|
||||
std::get<2>(t) = 0;
|
||||
assert(i == 0);
|
||||
assert(j == 0);
|
||||
}
|
||||
}
|
30
test/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp
Normal file
30
test/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp
Normal 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... Types>
|
||||
// tuple<Types&...> tie(Types&... t);
|
||||
|
||||
#include <tuple>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int i = 0;
|
||||
std::string s;
|
||||
std::tie(i, std::ignore, s) = std::make_tuple(42, 3.14, "C++");
|
||||
assert(i == 42);
|
||||
assert(s == "C++");
|
||||
}
|
||||
}
|
@@ -0,0 +1,115 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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... 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);
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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 <size_t I, class... Types>
|
||||
// typename tuple_element<I, tuple<Types...> >::type const&
|
||||
// get(const tuple<Types...>& t);
|
||||
|
||||
#include <tuple>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::tuple<double&, std::string, int> T;
|
||||
double d = 1.5;
|
||||
const T t(d, "high", 5);
|
||||
assert(std::get<0>(t) == 1.5);
|
||||
assert(std::get<1>(t) == "high");
|
||||
assert(std::get<2>(t) == 5);
|
||||
std::get<0>(t) = 2.5;
|
||||
assert(std::get<0>(t) == 2.5);
|
||||
assert(std::get<1>(t) == "high");
|
||||
assert(std::get<2>(t) == 5);
|
||||
assert(d == 2.5);
|
||||
|
||||
std::get<1>(t) = "four";
|
||||
}
|
||||
}
|
@@ -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;
|
||||
|
||||
// template <size_t I, class... Types>
|
||||
// typename tuple_element<I, tuple<Types...> >::type const&
|
||||
// get(const tuple<Types...>& t);
|
||||
|
||||
#include <tuple>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::tuple<int> T;
|
||||
const T t(3);
|
||||
assert(std::get<0>(t) == 3);
|
||||
}
|
||||
{
|
||||
typedef std::tuple<std::string, int> T;
|
||||
const T t("high", 5);
|
||||
assert(std::get<0>(t) == "high");
|
||||
assert(std::get<1>(t) == 5);
|
||||
}
|
||||
{
|
||||
typedef std::tuple<double&, std::string, int> T;
|
||||
double d = 1.5;
|
||||
const T t(d, "high", 5);
|
||||
assert(std::get<0>(t) == 1.5);
|
||||
assert(std::get<1>(t) == "high");
|
||||
assert(std::get<2>(t) == 5);
|
||||
std::get<0>(t) = 2.5;
|
||||
assert(std::get<0>(t) == 2.5);
|
||||
assert(std::get<1>(t) == "high");
|
||||
assert(std::get<2>(t) == 5);
|
||||
assert(d == 2.5);
|
||||
}
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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 <size_t I, class... Types>
|
||||
// typename tuple_element<I, tuple<Types...> >::type&
|
||||
// get(tuple<Types...>& t);
|
||||
|
||||
#include <tuple>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::tuple<int> T;
|
||||
T t(3);
|
||||
assert(std::get<0>(t) == 3);
|
||||
std::get<0>(t) = 2;
|
||||
assert(std::get<0>(t) == 2);
|
||||
}
|
||||
{
|
||||
typedef std::tuple<std::string, int> T;
|
||||
T t("high", 5);
|
||||
assert(std::get<0>(t) == "high");
|
||||
assert(std::get<1>(t) == 5);
|
||||
std::get<0>(t) = "four";
|
||||
std::get<1>(t) = 4;
|
||||
assert(std::get<0>(t) == "four");
|
||||
assert(std::get<1>(t) == 4);
|
||||
}
|
||||
{
|
||||
typedef std::tuple<double&, std::string, int> T;
|
||||
double d = 1.5;
|
||||
T t(d, "high", 5);
|
||||
assert(std::get<0>(t) == 1.5);
|
||||
assert(std::get<1>(t) == "high");
|
||||
assert(std::get<2>(t) == 5);
|
||||
std::get<0>(t) = 2.5;
|
||||
std::get<1>(t) = "four";
|
||||
std::get<2>(t) = 4;
|
||||
assert(std::get<0>(t) == 2.5);
|
||||
assert(std::get<1>(t) == "four");
|
||||
assert(std::get<2>(t) == 4);
|
||||
assert(d == 2.5);
|
||||
}
|
||||
}
|
@@ -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 <size_t I, class... Types>
|
||||
// class tuple_element<I, tuple<Types...> >
|
||||
// {
|
||||
// public:
|
||||
// typedef Ti type;
|
||||
// };
|
||||
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::tuple<int> T;
|
||||
static_assert((std::is_same<std::tuple_element<0, T>::type,
|
||||
int>::value), "");
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int> T;
|
||||
static_assert((std::is_same<std::tuple_element<0, T>::type,
|
||||
char>::value), "");
|
||||
static_assert((std::is_same<std::tuple_element<1, T>::type,
|
||||
int>::value), "");
|
||||
}
|
||||
{
|
||||
typedef std::tuple<int*, char, int> T;
|
||||
static_assert((std::is_same<std::tuple_element<0, T>::type,
|
||||
int*>::value), "");
|
||||
static_assert((std::is_same<std::tuple_element<1, T>::type,
|
||||
char>::value), "");
|
||||
static_assert((std::is_same<std::tuple_element<2, T>::type,
|
||||
int>::value), "");
|
||||
}
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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... Types>
|
||||
// class tuple_size<tuple<Types...>>
|
||||
// : public integral_constant<size_t, sizeof...(Types)> { };
|
||||
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::tuple<> T;
|
||||
static_assert((std::is_base_of<std::integral_constant<std::size_t, 0>,
|
||||
std::tuple_size<T> >::value), "");
|
||||
}
|
||||
{
|
||||
typedef std::tuple<int> T;
|
||||
static_assert((std::is_base_of<std::integral_constant<std::size_t, 1>,
|
||||
std::tuple_size<T> >::value), "");
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int> T;
|
||||
static_assert((std::is_base_of<std::integral_constant<std::size_t, 2>,
|
||||
std::tuple_size<T> >::value), "");
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, char*, int> T;
|
||||
static_assert((std::is_base_of<std::integral_constant<std::size_t, 3>,
|
||||
std::tuple_size<T> >::value), "");
|
||||
}
|
||||
}
|
33
test/utilities/tuple/tuple.tuple/tuple.range/begin.pass.cpp
Normal file
33
test/utilities/tuple/tuple.tuple/tuple.range/begin.pass.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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 InputIterator>
|
||||
// InputIterator begin(const tuple<InputIterator, InputIterator>& t);
|
||||
|
||||
// template <class InputIterator>
|
||||
// InputIterator end(const tuple<InputIterator, InputIterator>& t);
|
||||
|
||||
#include <tuple>
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::tuple<int*, int*> T;
|
||||
int array[5] = {0, 1, 2, 3, 4};
|
||||
const T t(std::begin(array), std::end(array));
|
||||
assert(begin(t) == std::begin(array));
|
||||
assert(end(t) == std::end(array));
|
||||
}
|
||||
}
|
144
test/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp
Normal file
144
test/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp
Normal file
@@ -0,0 +1,144 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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... TTypes, class... UTypes>
|
||||
// bool
|
||||
// operator==(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
|
||||
|
||||
#include <tuple>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::tuple<> T1;
|
||||
typedef std::tuple<> T2;
|
||||
const T1 t1;
|
||||
const T2 t2;
|
||||
assert(t1 == t2);
|
||||
assert(!(t1 != t2));
|
||||
}
|
||||
{
|
||||
typedef std::tuple<int> T1;
|
||||
typedef std::tuple<double> T2;
|
||||
const T1 t1(1);
|
||||
const T2 t2(1.1);
|
||||
assert(!(t1 == t2));
|
||||
assert(t1 != t2);
|
||||
}
|
||||
{
|
||||
typedef std::tuple<int> T1;
|
||||
typedef std::tuple<double> T2;
|
||||
const T1 t1(1);
|
||||
const T2 t2(1);
|
||||
assert(t1 == t2);
|
||||
assert(!(t1 != t2));
|
||||
}
|
||||
{
|
||||
typedef std::tuple<int, double> T1;
|
||||
typedef std::tuple<double, char> T2;
|
||||
const T1 t1(1, 2);
|
||||
const T2 t2(1, char(2));
|
||||
assert(t1 == t2);
|
||||
assert(!(t1 != t2));
|
||||
}
|
||||
{
|
||||
typedef std::tuple<int, double> T1;
|
||||
typedef std::tuple<double, char> T2;
|
||||
const T1 t1(1, 2);
|
||||
const T2 t2(1, char(3));
|
||||
assert(!(t1 == t2));
|
||||
assert(t1 != t2);
|
||||
}
|
||||
{
|
||||
typedef std::tuple<int, double> T1;
|
||||
typedef std::tuple<double, char> T2;
|
||||
const T1 t1(1, 2);
|
||||
const T2 t2(1.1, char(2));
|
||||
assert(!(t1 == t2));
|
||||
assert(t1 != t2);
|
||||
}
|
||||
{
|
||||
typedef std::tuple<int, double> T1;
|
||||
typedef std::tuple<double, char> T2;
|
||||
const T1 t1(1, 2);
|
||||
const T2 t2(1.1, char(3));
|
||||
assert(!(t1 == t2));
|
||||
assert(t1 != t2);
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int, double> T1;
|
||||
typedef std::tuple<double, char, int> T2;
|
||||
const T1 t1(1, 2, 3);
|
||||
const T2 t2(1, 2, 3);
|
||||
assert(t1 == t2);
|
||||
assert(!(t1 != t2));
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int, double> T1;
|
||||
typedef std::tuple<double, char, int> T2;
|
||||
const T1 t1(1, 2, 3);
|
||||
const T2 t2(1.1, 2, 3);
|
||||
assert(!(t1 == t2));
|
||||
assert(t1 != t2);
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int, double> T1;
|
||||
typedef std::tuple<double, char, int> T2;
|
||||
const T1 t1(1, 2, 3);
|
||||
const T2 t2(1, 3, 3);
|
||||
assert(!(t1 == t2));
|
||||
assert(t1 != t2);
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int, double> T1;
|
||||
typedef std::tuple<double, char, int> T2;
|
||||
const T1 t1(1, 2, 3);
|
||||
const T2 t2(1, 2, 4);
|
||||
assert(!(t1 == t2));
|
||||
assert(t1 != t2);
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int, double> T1;
|
||||
typedef std::tuple<double, char, int> T2;
|
||||
const T1 t1(1, 2, 3);
|
||||
const T2 t2(1, 3, 2);
|
||||
assert(!(t1 == t2));
|
||||
assert(t1 != t2);
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int, double> T1;
|
||||
typedef std::tuple<double, char, int> T2;
|
||||
const T1 t1(1, 2, 3);
|
||||
const T2 t2(1.1, 2, 2);
|
||||
assert(!(t1 == t2));
|
||||
assert(t1 != t2);
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int, double> T1;
|
||||
typedef std::tuple<double, char, int> T2;
|
||||
const T1 t1(1, 2, 3);
|
||||
const T2 t2(1.1, 3, 3);
|
||||
assert(!(t1 == t2));
|
||||
assert(t1 != t2);
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int, double> T1;
|
||||
typedef std::tuple<double, char, int> T2;
|
||||
const T1 t1(1, 2, 3);
|
||||
const T2 t2(1.1, 3, 2);
|
||||
assert(!(t1 == t2));
|
||||
assert(t1 != t2);
|
||||
}
|
||||
}
|
196
test/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp
Normal file
196
test/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp
Normal file
@@ -0,0 +1,196 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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... TTypes, class... UTypes>
|
||||
// bool
|
||||
// operator<(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
|
||||
//
|
||||
// template<class... TTypes, class... UTypes>
|
||||
// bool
|
||||
// operator>(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
|
||||
//
|
||||
// template<class... TTypes, class... UTypes>
|
||||
// bool
|
||||
// operator<=(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
|
||||
//
|
||||
// template<class... TTypes, class... UTypes>
|
||||
// bool
|
||||
// operator>=(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
|
||||
|
||||
#include <tuple>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::tuple<> T1;
|
||||
typedef std::tuple<> T2;
|
||||
const T1 t1;
|
||||
const T2 t2;
|
||||
assert(!(t1 < t2));
|
||||
assert( (t1 <= t2));
|
||||
assert(!(t1 > t2));
|
||||
assert( (t1 >= t2));
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char> T1;
|
||||
typedef std::tuple<double> T2;
|
||||
const T1 t1(1);
|
||||
const T2 t2(1);
|
||||
assert(!(t1 < t2));
|
||||
assert( (t1 <= t2));
|
||||
assert(!(t1 > t2));
|
||||
assert( (t1 >= t2));
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char> T1;
|
||||
typedef std::tuple<double> T2;
|
||||
const T1 t1(1);
|
||||
const T2 t2(0.9);
|
||||
assert(!(t1 < t2));
|
||||
assert(!(t1 <= t2));
|
||||
assert( (t1 > t2));
|
||||
assert( (t1 >= t2));
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char> T1;
|
||||
typedef std::tuple<double> T2;
|
||||
const T1 t1(1);
|
||||
const T2 t2(1.1);
|
||||
assert( (t1 < t2));
|
||||
assert( (t1 <= t2));
|
||||
assert(!(t1 > t2));
|
||||
assert(!(t1 >= t2));
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int> T1;
|
||||
typedef std::tuple<double, char> T2;
|
||||
const T1 t1(1, 2);
|
||||
const T2 t2(1, 2);
|
||||
assert(!(t1 < t2));
|
||||
assert( (t1 <= t2));
|
||||
assert(!(t1 > t2));
|
||||
assert( (t1 >= t2));
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int> T1;
|
||||
typedef std::tuple<double, char> T2;
|
||||
const T1 t1(1, 2);
|
||||
const T2 t2(0.9, 2);
|
||||
assert(!(t1 < t2));
|
||||
assert(!(t1 <= t2));
|
||||
assert( (t1 > t2));
|
||||
assert( (t1 >= t2));
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int> T1;
|
||||
typedef std::tuple<double, char> T2;
|
||||
const T1 t1(1, 2);
|
||||
const T2 t2(1.1, 2);
|
||||
assert( (t1 < t2));
|
||||
assert( (t1 <= t2));
|
||||
assert(!(t1 > t2));
|
||||
assert(!(t1 >= t2));
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int> T1;
|
||||
typedef std::tuple<double, char> T2;
|
||||
const T1 t1(1, 2);
|
||||
const T2 t2(1, 1);
|
||||
assert(!(t1 < t2));
|
||||
assert(!(t1 <= t2));
|
||||
assert( (t1 > t2));
|
||||
assert( (t1 >= t2));
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int> T1;
|
||||
typedef std::tuple<double, char> T2;
|
||||
const T1 t1(1, 2);
|
||||
const T2 t2(1, 3);
|
||||
assert( (t1 < t2));
|
||||
assert( (t1 <= t2));
|
||||
assert(!(t1 > t2));
|
||||
assert(!(t1 >= t2));
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int, double> T1;
|
||||
typedef std::tuple<double, char, int> T2;
|
||||
const T1 t1(1, 2, 3);
|
||||
const T2 t2(1, 2, 3);
|
||||
assert(!(t1 < t2));
|
||||
assert( (t1 <= t2));
|
||||
assert(!(t1 > t2));
|
||||
assert( (t1 >= t2));
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int, double> T1;
|
||||
typedef std::tuple<double, char, int> T2;
|
||||
const T1 t1(1, 2, 3);
|
||||
const T2 t2(0.9, 2, 3);
|
||||
assert(!(t1 < t2));
|
||||
assert(!(t1 <= t2));
|
||||
assert( (t1 > t2));
|
||||
assert( (t1 >= t2));
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int, double> T1;
|
||||
typedef std::tuple<double, char, int> T2;
|
||||
const T1 t1(1, 2, 3);
|
||||
const T2 t2(1.1, 2, 3);
|
||||
assert( (t1 < t2));
|
||||
assert( (t1 <= t2));
|
||||
assert(!(t1 > t2));
|
||||
assert(!(t1 >= t2));
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int, double> T1;
|
||||
typedef std::tuple<double, char, int> T2;
|
||||
const T1 t1(1, 2, 3);
|
||||
const T2 t2(1, 1, 3);
|
||||
assert(!(t1 < t2));
|
||||
assert(!(t1 <= t2));
|
||||
assert( (t1 > t2));
|
||||
assert( (t1 >= t2));
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int, double> T1;
|
||||
typedef std::tuple<double, char, int> T2;
|
||||
const T1 t1(1, 2, 3);
|
||||
const T2 t2(1, 3, 3);
|
||||
assert( (t1 < t2));
|
||||
assert( (t1 <= t2));
|
||||
assert(!(t1 > t2));
|
||||
assert(!(t1 >= t2));
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int, double> T1;
|
||||
typedef std::tuple<double, char, int> T2;
|
||||
const T1 t1(1, 2, 3);
|
||||
const T2 t2(1, 2, 2);
|
||||
assert(!(t1 < t2));
|
||||
assert(!(t1 <= t2));
|
||||
assert( (t1 > t2));
|
||||
assert( (t1 >= t2));
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int, double> T1;
|
||||
typedef std::tuple<double, char, int> T2;
|
||||
const T1 t1(1, 2, 3);
|
||||
const T2 t2(1, 2, 4);
|
||||
assert( (t1 < t2));
|
||||
assert( (t1 <= t2));
|
||||
assert(!(t1 > t2));
|
||||
assert(!(t1 >= t2));
|
||||
}
|
||||
}
|
@@ -0,0 +1,60 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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... Types>
|
||||
// void swap(tuple<Types...>& x, tuple<Types...>& y);
|
||||
|
||||
#include <tuple>
|
||||
#include <cassert>
|
||||
|
||||
#include "../MoveOnly.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::tuple<> T;
|
||||
T t0;
|
||||
T t1;
|
||||
swap(t0, t1);
|
||||
}
|
||||
{
|
||||
typedef std::tuple<MoveOnly> T;
|
||||
T t0(MoveOnly(0));
|
||||
T t1(MoveOnly(1));
|
||||
swap(t0, t1);
|
||||
assert(std::get<0>(t0) == 1);
|
||||
assert(std::get<0>(t1) == 0);
|
||||
}
|
||||
{
|
||||
typedef std::tuple<MoveOnly, MoveOnly> T;
|
||||
T t0(MoveOnly(0), MoveOnly(1));
|
||||
T t1(MoveOnly(2), MoveOnly(3));
|
||||
swap(t0, t1);
|
||||
assert(std::get<0>(t0) == 2);
|
||||
assert(std::get<1>(t0) == 3);
|
||||
assert(std::get<0>(t1) == 0);
|
||||
assert(std::get<1>(t1) == 1);
|
||||
}
|
||||
{
|
||||
typedef std::tuple<MoveOnly, MoveOnly, MoveOnly> T;
|
||||
T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2));
|
||||
T t1(MoveOnly(3), MoveOnly(4), MoveOnly(5));
|
||||
swap(t0, t1);
|
||||
assert(std::get<0>(t0) == 3);
|
||||
assert(std::get<1>(t0) == 4);
|
||||
assert(std::get<2>(t0) == 5);
|
||||
assert(std::get<0>(t1) == 0);
|
||||
assert(std::get<1>(t1) == 1);
|
||||
assert(std::get<2>(t1) == 2);
|
||||
}
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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;
|
||||
|
||||
// void swap(tuple& rhs);
|
||||
|
||||
#include <tuple>
|
||||
#include <cassert>
|
||||
|
||||
#include "../MoveOnly.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::tuple<> T;
|
||||
T t0;
|
||||
T t1;
|
||||
t0.swap(t1);
|
||||
}
|
||||
{
|
||||
typedef std::tuple<MoveOnly> T;
|
||||
T t0(MoveOnly(0));
|
||||
T t1(MoveOnly(1));
|
||||
t0.swap(t1);
|
||||
assert(std::get<0>(t0) == 1);
|
||||
assert(std::get<0>(t1) == 0);
|
||||
}
|
||||
{
|
||||
typedef std::tuple<MoveOnly, MoveOnly> T;
|
||||
T t0(MoveOnly(0), MoveOnly(1));
|
||||
T t1(MoveOnly(2), MoveOnly(3));
|
||||
t0.swap(t1);
|
||||
assert(std::get<0>(t0) == 2);
|
||||
assert(std::get<1>(t0) == 3);
|
||||
assert(std::get<0>(t1) == 0);
|
||||
assert(std::get<1>(t1) == 1);
|
||||
}
|
||||
{
|
||||
typedef std::tuple<MoveOnly, MoveOnly, MoveOnly> T;
|
||||
T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2));
|
||||
T t1(MoveOnly(3), MoveOnly(4), MoveOnly(5));
|
||||
t0.swap(t1);
|
||||
assert(std::get<0>(t0) == 3);
|
||||
assert(std::get<1>(t0) == 4);
|
||||
assert(std::get<2>(t0) == 5);
|
||||
assert(std::get<0>(t1) == 0);
|
||||
assert(std::get<1>(t1) == 1);
|
||||
assert(std::get<2>(t1) == 2);
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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... Types, class Alloc>
|
||||
// struct uses_allocator<tuple<Types...>, Alloc> : true_type { };
|
||||
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
|
||||
struct A {};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::tuple<> T;
|
||||
static_assert((std::is_base_of<std::true_type,
|
||||
std::uses_allocator<T, A>>::value), "");
|
||||
}
|
||||
{
|
||||
typedef std::tuple<int> T;
|
||||
static_assert((std::is_base_of<std::true_type,
|
||||
std::uses_allocator<T, A>>::value), "");
|
||||
}
|
||||
{
|
||||
typedef std::tuple<char, int> T;
|
||||
static_assert((std::is_base_of<std::true_type,
|
||||
std::uses_allocator<T, A>>::value), "");
|
||||
}
|
||||
{
|
||||
typedef std::tuple<double&, char, int> T;
|
||||
static_assert((std::is_base_of<std::true_type,
|
||||
std::uses_allocator<T, A>>::value), "");
|
||||
}
|
||||
}
|
20
test/utilities/tuple/version.pass.cpp
Normal file
20
test/utilities/tuple/version.pass.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <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>
|
||||
|
||||
#include <tuple>
|
||||
|
||||
#ifndef _LIBCPP_VERSION
|
||||
#error _LIBCPP_VERSION not defined
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user