git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@119545 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant
2010-11-17 19:52:17 +00:00
parent 86ed8aefb2
commit cd2254b454
7 changed files with 164 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <array>
// template <size_t I, class T, size_t N> T&& get(array<T, N>&& a);
#include <array>
#include <memory>
#include <cassert>
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::unique_ptr<double> T;
typedef std::array<T, 1> C;
C c = {std::unique_ptr<double>(new double(3.5))};
T t = std::get<0>(std::move(c));
assert(*t == 3.5);
}
#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.
//
//===----------------------------------------------------------------------===//
// <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 <memory>
#include <cassert>
int main()
{
{
typedef std::tuple<std::unique_ptr<int> > T;
T t(std::unique_ptr<int>(new int(3)));
std::unique_ptr<int> p = std::get<0>(std::move(t));
assert(*p == 3);
}
}

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
}