Home | History | Annotate | Download | only in dynarray.overview
      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 // UNSUPPORTED: c++98, c++03, c++11
     11 // dynarray.overview
     12 
     13 // size_type size()     const noexcept;
     14 // size_type max_size() const noexcept;
     15 // bool      empty()    const noexcept;
     16 
     17 #include <__config>
     18 
     19 #include <experimental/dynarray>
     20 #include <cassert>
     21 
     22 #include <algorithm>
     23 #include <complex>
     24 #include <string>
     25 
     26 using std::experimental::dynarray;
     27 
     28 template <class T>
     29 void dyn_test ( const dynarray<T> &dyn, size_t sz ) {
     30     assert ( dyn.size ()     == sz );
     31     assert ( dyn.max_size () == sz );
     32     assert ( dyn.empty () == ( sz == 0 ));
     33     }
     34 
     35 template <class T>
     36 void test ( std::initializer_list<T> vals ) {
     37     typedef dynarray<T> dynA;
     38 
     39     dynA d1 ( vals );
     40     dyn_test ( d1, vals.size ());
     41     }
     42 
     43 int main()
     44 {
     45     test ( { 1, 1, 2, 3, 5, 8 } );
     46     test ( { 1., 1., 2., 3., 5., 8. } );
     47     test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
     48                 std::string("5"), std::string("8")} );
     49 
     50     test<int> ( {} );
     51     test<std::complex<double>> ( {} );
     52     test<std::string> ( {} );
     53 }
     54 
     55