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