Move test into test/std subdirectory.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2014-12-20 01:40:03 +00:00
parent 669a8a5a19
commit a90c6dd460
4817 changed files with 13 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
int main()
{
}

View File

@@ -0,0 +1,30 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2> struct pair
// template<size_t I, class T1, class T2>
// const typename tuple_element<I, std::pair<T1, T2> >::type&
// get(const pair<T1, T2>&);
#include <utility>
#include <cassert>
int main()
{
{
typedef std::pair<int, short> P;
const P p(3, 4);
assert(std::get<0>(p) == 3);
assert(std::get<1>(p) == 4);
std::get<0>(p) = 5;
}
}

View File

@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2> struct pair
// template<size_t I, class T1, class T2>
// const typename tuple_element<I, std::pair<T1, T2> >::type&
// get(const pair<T1, T2>&);
#include <utility>
#include <cassert>
int main()
{
{
typedef std::pair<int, short> P;
const P p(3, 4);
assert(std::get<0>(p) == 3);
assert(std::get<1>(p) == 4);
}
#if __cplusplus > 201103L
{
typedef std::pair<int, short> P;
constexpr P p1(3, 4);
static_assert(std::get<0>(p1) == 3, "");
static_assert(std::get<1>(p1) == 4, "");
}
#endif
}

View File

@@ -0,0 +1,51 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2> struct pair
// template<size_t I, class T1, class T2>
// typename tuple_element<I, std::pair<T1, T2> >::type&
// get(pair<T1, T2>&);
#include <utility>
#include <cassert>
#if __cplusplus > 201103L
struct S {
std::pair<int, int> a;
int k;
constexpr S() : a{1,2}, k(std::get<0>(a)) {}
};
constexpr std::pair<int, int> getP () { return { 3, 4 }; }
#endif
int main()
{
{
typedef std::pair<int, short> P;
P p(3, 4);
assert(std::get<0>(p) == 3);
assert(std::get<1>(p) == 4);
std::get<0>(p) = 5;
std::get<1>(p) = 6;
assert(std::get<0>(p) == 5);
assert(std::get<1>(p) == 6);
}
#if __cplusplus > 201103L
{
static_assert(S().k == 1, "");
static_assert(std::get<1>(getP()) == 4, "");
}
#endif
}

View File

@@ -0,0 +1,32 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2> struct pair
// template<size_t I, class T1, class T2>
// typename tuple_element<I, std::pair<T1, T2> >::type&&
// get(pair<T1, T2>&&);
#include <utility>
#include <memory>
#include <cassert>
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::pair<std::unique_ptr<int>, short> P;
P p(std::unique_ptr<int>(new int(3)), 4);
std::unique_ptr<int> ptr = std::get<0>(std::move(p));
assert(*ptr == 3);
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,44 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include <utility>
#include <string>
#include <complex>
#include <cassert>
int main()
{
#if _LIBCPP_STD_VER > 11
typedef std::complex<float> cf;
{
auto t1 = std::make_pair<int, cf> ( 42, { 1,2 } );
assert ( std::get<int>(t1) == 42 );
assert ( std::get<cf>(t1).real() == 1 );
assert ( std::get<cf>(t1).imag() == 2 );
}
{
const std::pair<int, const int> p1 { 1, 2 };
const int &i1 = std::get<int>(p1);
const int &i2 = std::get<const int>(p1);
assert ( i1 == 1 );
assert ( i2 == 2 );
}
{
typedef std::unique_ptr<int> upint;
std::pair<upint, int> t(upint(new int(4)), 42);
upint p = std::get<0>(std::move(t)); // get rvalue
assert(*p == 4);
assert(std::get<0>(t) == nullptr); // has been moved from
}
#endif
}

View File

@@ -0,0 +1,24 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include <utility>
#include <complex>
#include <cassert>
int main()
{
#if _LIBCPP_STD_VER > 11
typedef std::complex<float> cf;
auto t1 = std::make_pair<int, double> ( 42, 3.4 );
assert (( std::get<cf>(t1) == cf {1,2} )); // no such type
#else
#error
#endif
}

View File

@@ -0,0 +1,24 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include <utility>
#include <complex>
#include <cassert>
int main()
{
#if _LIBCPP_STD_VER > 11
typedef std::complex<float> cf;
auto t1 = std::make_pair<int, int> ( 42, 43 );
assert ( std::get<int>(t1) == 42 ); // two ints
#else
#error
#endif
}

View File

@@ -0,0 +1,24 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include <utility>
#include <complex>
#include <cassert>
int main()
{
#if _LIBCPP_STD_VER > 11
typedef std::unique_ptr<int> upint;
std::pair<upint, int> t(upint(new int(4)), 23);
upint p = std::get<upint>(t);
#else
#error
#endif
}

View File

@@ -0,0 +1,30 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2> struct pair
// tuple_element<I, pair<T1, T2> >::type
#include <utility>
int main()
{
{
typedef std::pair<int, short> P1;
static_assert((std::is_same<std::tuple_element<0, P1>::type, int>::value), "");
static_assert((std::is_same<std::tuple_element<1, P1>::type, short>::value), "");
}
{
typedef std::pair<int*, char> P1;
static_assert((std::is_same<std::tuple_element<0, P1>::type, int*>::value), "");
static_assert((std::is_same<std::tuple_element<1, P1>::type, char>::value), "");
}
}

View File

@@ -0,0 +1,24 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2> struct pair
// tuple_size<pair<T1, T2> >::value
#include <utility>
int main()
{
{
typedef std::pair<int, short> P1;
static_assert((std::tuple_size<P1>::value == 2), "");
}
}

View File

@@ -0,0 +1,55 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2> struct pair
// struct piecewise_construct_t { };
// constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
#include <utility>
#include <tuple>
#include <cassert>
class A
{
int i_;
char c_;
public:
A(int i, char c) : i_(i), c_(c) {}
int get_i() const {return i_;}
char get_c() const {return c_;}
};
class B
{
double d_;
unsigned u1_;
unsigned u2_;
public:
B(double d, unsigned u1, unsigned u2) : d_(d), u1_(u1), u2_(u2) {}
double get_d() const {return d_;}
unsigned get_u1() const {return u1_;}
unsigned get_u2() const {return u2_;}
};
int main()
{
#ifndef _LIBCPP_HAS_NO_VARIADICS
std::pair<A, B> p(std::piecewise_construct,
std::make_tuple(4, 'a'),
std::make_tuple(3.5, 6u, 2u));
assert(p.first.get_i() == 4);
assert(p.first.get_c() == 'a');
assert(p.second.get_d() == 3.5);
assert(p.second.get_u1() == 6u);
assert(p.second.get_u2() == 2u);
#endif
}

View File

@@ -0,0 +1,12 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
int main()
{
}

View File

@@ -0,0 +1,30 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2> struct pair
// template<class U, class V> pair(U&& x, V&& y);
#include <utility>
#include <memory>
#include <cassert>
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::pair<std::unique_ptr<int>, short*> P;
P p(std::unique_ptr<int>(new int(3)), nullptr);
assert(*p.first == 3);
assert(p.second == nullptr);
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,30 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2> struct pair
// template<class U, class V> pair& operator=(const pair<U, V>& p);
#include <utility>
#include <cassert>
int main()
{
{
typedef std::pair<int, short> P1;
typedef std::pair<double, long> P2;
P1 p1(3, 4);
P2 p2;
p2 = p1;
assert(p2.first == 3);
assert(p2.second == 4);
}
}

View File

@@ -0,0 +1,32 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2> struct pair
// pair& operator=(pair&& p);
#include <utility>
#include <memory>
#include <cassert>
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::pair<std::unique_ptr<int>, short> P;
P p1(std::unique_ptr<int>(new int(3)), 4);
P p2;
p2 = std::move(p1);
assert(*p2.first == 3);
assert(p2.second == 4);
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,43 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2> struct pair
// template<class U, class V> pair& operator=(pair<U, V>&& p);
#include <utility>
#include <memory>
#include <cassert>
struct Base
{
virtual ~Base() {}
};
struct Derived
: public Base
{
};
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::pair<std::unique_ptr<Derived>, short> P1;
typedef std::pair<std::unique_ptr<Base>, long> P2;
P1 p1(std::unique_ptr<Derived>(), 4);
P2 p2;
p2 = std::move(p1);
assert(p2.first == nullptr);
assert(p2.second == 4);
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,68 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2> struct pair
// pair(const T1& x, const T2& y);
#include <utility>
#include <cassert>
class A
{
int data_;
public:
A(int data) : data_(data) {}
bool operator==(const A& a) const {return data_ == a.data_;}
};
#if _LIBCPP_STD_VER > 11
class AC
{
int data_;
public:
constexpr AC(int data) : data_(data) {}
constexpr bool operator==(const AC& a) const {return data_ == a.data_;}
};
#endif
int main()
{
{
typedef std::pair<float, short*> P;
P p(3.5f, 0);
assert(p.first == 3.5f);
assert(p.second == nullptr);
}
{
typedef std::pair<A, int> P;
P p(1, 2);
assert(p.first == A(1));
assert(p.second == 2);
}
#if _LIBCPP_STD_VER > 11
{
typedef std::pair<float, short*> P;
constexpr P p(3.5f, 0);
static_assert(p.first == 3.5f, "");
static_assert(p.second == nullptr, "");
}
{
typedef std::pair<AC, int> P;
constexpr P p(1, 2);
static_assert(p.first == AC(1), "");
static_assert(p.second == 2, "");
}
#endif
}

View File

@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2> struct pair
// template <class U, class V> pair(const pair<U, V>& p);
#include <utility>
#include <cassert>
int main()
{
{
typedef std::pair<int, short> P1;
typedef std::pair<double, long> P2;
P1 p1(3, 4);
P2 p2 = p1;
assert(p2.first == 3);
assert(p2.second == 4);
}
#if _LIBCPP_STD_VER > 11
{
typedef std::pair<int, short> P1;
typedef std::pair<double, long> P2;
constexpr P1 p1(3, 4);
constexpr P2 p2 = p1;
static_assert(p2.first == 3, "");
static_assert(p2.second == 4, "");
}
#endif
}

View File

@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2> struct pair
// pair(const pair&) = default;
#include <utility>
#include <cassert>
int main()
{
{
typedef std::pair<int, short> P1;
P1 p1(3, 4);
P1 p2 = p1;
assert(p2.first == 3);
assert(p2.second == 4);
}
static_assert((std::is_trivially_copy_constructible<std::pair<int, int> >::value), "");
#if _LIBCPP_STD_VER > 11
{
typedef std::pair<int, short> P1;
constexpr P1 p1(3, 4);
constexpr P1 p2 = p1;
static_assert(p2.first == 3, "");
static_assert(p2.second == 4, "");
}
#endif
}

View File

@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2> struct pair
// constexpr pair();
#include <utility>
#include <cassert>
int main()
{
{
typedef std::pair<float, short*> P;
P p;
assert(p.first == 0.0f);
assert(p.second == nullptr);
}
#if _LIBCPP_STD_VER > 11
{
typedef std::pair<float, short*> P;
constexpr P p;
static_assert(p.first == 0.0f, "");
static_assert(p.second == nullptr, "");
}
#endif
}

View File

@@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2> struct pair
// template <class... Args1, class... Args2>
// pair(piecewise_construct_t, tuple<Args1...> first_args,
// tuple<Args2...> second_args);
#include <utility>
#include <tuple>
#include <cassert>
int main()
{
#ifndef _LIBCPP_HAS_NO_VARIADICS
{
typedef std::pair<int, int*> P1;
typedef std::pair<int*, int> P2;
typedef std::pair<P1, P2> P3;
P3 p3(std::piecewise_construct, std::tuple<int, int*>(3, nullptr),
std::tuple<int*, int>(nullptr, 4));
assert(p3.first == P1(3, nullptr));
assert(p3.second == P2(nullptr, 4));
}
#endif // _LIBCPP_HAS_NO_VARIADICS
}

View File

@@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2> struct pair
// template <class U, class V> pair(pair<U, V>&& p);
#include <utility>
#include <memory>
#include <cassert>
struct Base
{
virtual ~Base() {}
};
struct Derived
: public Base
{
};
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::pair<std::unique_ptr<Derived>, short> P1;
typedef std::pair<std::unique_ptr<Base>, long> P2;
P1 p1(std::unique_ptr<Derived>(), 4);
P2 p2 = std::move(p1);
assert(p2.first == nullptr);
assert(p2.second == 4);
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2> struct pair
// void swap(pair& p);
#include <utility>
#include <cassert>
int main()
{
{
typedef std::pair<int, short> P1;
P1 p1(3, 4);
P1 p2(5, 6);
p1.swap(p2);
assert(p1.first == 5);
assert(p1.second == 6);
assert(p2.first == 3);
assert(p2.second == 4);
}
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2>
// struct pair
// {
// typedef T1 first_type;
// typedef T2 second_type;
#include <utility>
#include <type_traits>
int main()
{
typedef std::pair<float, short*> P;
static_assert((std::is_same<P::first_type, float>::value), "");
static_assert((std::is_same<P::second_type, short*>::value), "");
}

View File

@@ -0,0 +1,95 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2> struct pair
// template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&);
// template <class T1, class T2> bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&);
// template <class T1, class T2> bool operator< (const pair<T1,T2>&, const pair<T1,T2>&);
// template <class T1, class T2> bool operator> (const pair<T1,T2>&, const pair<T1,T2>&);
// template <class T1, class T2> bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&);
// template <class T1, class T2> bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&);
#include <utility>
#include <cassert>
int main()
{
{
typedef std::pair<int, short> P;
P p1(3, 4);
P p2(3, 4);
assert( (p1 == p2));
assert(!(p1 != p2));
assert(!(p1 < p2));
assert( (p1 <= p2));
assert(!(p1 > p2));
assert( (p1 >= p2));
}
{
typedef std::pair<int, short> P;
P p1(2, 4);
P p2(3, 4);
assert(!(p1 == p2));
assert( (p1 != p2));
assert( (p1 < p2));
assert( (p1 <= p2));
assert(!(p1 > p2));
assert(!(p1 >= p2));
}
{
typedef std::pair<int, short> P;
P p1(3, 2);
P p2(3, 4);
assert(!(p1 == p2));
assert( (p1 != p2));
assert( (p1 < p2));
assert( (p1 <= p2));
assert(!(p1 > p2));
assert(!(p1 >= p2));
}
{
typedef std::pair<int, short> P;
P p1(3, 4);
P p2(2, 4);
assert(!(p1 == p2));
assert( (p1 != p2));
assert(!(p1 < p2));
assert(!(p1 <= p2));
assert( (p1 > p2));
assert( (p1 >= p2));
}
{
typedef std::pair<int, short> P;
P p1(3, 4);
P p2(3, 2);
assert(!(p1 == p2));
assert( (p1 != p2));
assert(!(p1 < p2));
assert(!(p1 <= p2));
assert( (p1 > p2));
assert( (p1 >= p2));
}
#if _LIBCPP_STD_VER > 11
{
typedef std::pair<int, short> P;
constexpr P p1(3, 4);
constexpr P p2(3, 2);
static_assert(!(p1 == p2), "");
static_assert( (p1 != p2), "");
static_assert(!(p1 < p2), "");
static_assert(!(p1 <= p2), "");
static_assert( (p1 > p2), "");
static_assert( (p1 >= p2), "");
}
#endif
}

View File

@@ -0,0 +1,51 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2> pair<V1, V2> make_pair(T1&&, T2&&);
#include <utility>
#include <memory>
#include <cassert>
int main()
{
{
typedef std::pair<int, short> P1;
P1 p1 = std::make_pair(3, 4);
assert(p1.first == 3);
assert(p1.second == 4);
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::pair<std::unique_ptr<int>, short> P1;
P1 p1 = std::make_pair(std::unique_ptr<int>(new int(3)), 4);
assert(*p1.first == 3);
assert(p1.second == 4);
}
{
typedef std::pair<std::unique_ptr<int>, short> P1;
P1 p1 = std::make_pair(nullptr, 4);
assert(p1.first == nullptr);
assert(p1.second == 4);
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#if _LIBCPP_STD_VER > 11
{
typedef std::pair<int, short> P1;
constexpr P1 p1 = std::make_pair(3, 4);
static_assert(p1.first == 3, "");
static_assert(p1.second == 4, "");
}
#endif
}

View File

@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <utility>
// template <class T1, class T2> struct pair
// template <class T1, class T2> void swap(pair<T1, T2>& x, pair<T1, T2>& y);
#include <utility>
#include <cassert>
int main()
{
{
typedef std::pair<int, short> P1;
P1 p1(3, 4);
P1 p2(5, 6);
swap(p1, p2);
assert(p1.first == 5);
assert(p1.second == 6);
assert(p2.first == 3);
assert(p2.second == 4);
}
}