ctor_move.pass.cpp revision 06086258d3d8c48a916ec51c33e1ad8f46821b81
1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <stack> 11 12// stack(stack&& q); 13 14#include <stack> 15#include <cassert> 16 17#include "../../../MoveOnly.h" 18 19#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 20 21template <class C> 22C 23make(int n) 24{ 25 C c; 26 for (int i = 0; i < n; ++i) 27 c.push_back(MoveOnly(i)); 28 return c; 29} 30 31#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 32 33int main() 34{ 35#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 36 std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5)); 37 std::stack<MoveOnly> q2 = std::move(q); 38 assert(q2.size() == 5); 39 assert(q.empty()); 40#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 41} 42