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 // dynarray.overview 11 12 // reference front(); 13 // const_reference front() const; 14 // reference back(); 15 // const_reference back() const; 16 17 18 #include <__config> 19 20 #if _LIBCPP_STD_VER > 11 21 22 #include <experimental/dynarray> 23 #include <cassert> 24 25 #include <algorithm> 26 #include <complex> 27 #include <string> 28 29 using std::experimental::dynarray; 30 31 template <class T> dyn_test_const(const dynarray<T> & dyn)32void dyn_test_const ( const dynarray<T> &dyn ) { 33 const T *data = dyn.data (); 34 assert ( *data == dyn.front ()); 35 assert ( *(data + dyn.size() - 1 ) == dyn.back ()); 36 } 37 38 template <class T> dyn_test(dynarray<T> & dyn)39void dyn_test ( dynarray<T> &dyn ) { 40 T *data = dyn.data (); 41 assert ( *data == dyn.front ()); 42 assert ( *(data + dyn.size() - 1 ) == dyn.back ()); 43 } 44 45 46 template <class T> test(const T & val)47void test ( const T &val ) { 48 typedef dynarray<T> dynA; 49 50 dynA d1 ( 4 ); 51 dyn_test ( d1 ); 52 dyn_test_const ( d1 ); 53 54 dynA d2 ( 7, val ); 55 dyn_test ( d2 ); 56 dyn_test_const ( d2 ); 57 } 58 main()59int main() 60 { 61 test<int> ( 14 ); 62 test<double> ( 14.0 ); 63 test<std::complex<double>> ( std::complex<double> ( 14, 0 )); 64 test<std::string> ( "fourteen" ); 65 } 66 #else main()67int main() {} 68 #endif 69