libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

ctor_container.pass.cpp (830B)


      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 // explicit stack(const container_type& c);
     13 
     14 #include <stack>
     15 #include <cassert>
     16 #include <cstddef>
     17 
     18 template <class C>
     19 C
     20 make(int n)
     21 {
     22     C c;
     23     for (int i = 0; i < n; ++i)
     24         c.push_back(i);
     25     return c;
     26 }
     27 
     28 int main()
     29 {
     30     std::deque<int> d = make<std::deque<int> >(5);
     31     std::stack<int> q(d);
     32     assert(q.size() == 5);
     33     for (std::size_t i = 0; i < d.size(); ++i)
     34     {
     35         assert(q.top() == d[d.size() - i - 1]);
     36         q.pop();
     37     }
     38 }