2004-10-21 Benjamin Kosnik * include/tr1/array (array): Make safe for zero-sized arrays. (array::end): Return one past the end. (array::at): Use __throw_out_of_range, include functexcept.h. (operator==): Implement. (operator!=): Same. (operator<): Same. (operator>): Same. (operator>=): Same. (operator<=): Same. * testsuite/tr1/6_containers/array/capacity/(empty.cc, max_size.cc, size.cc): New. * testsuite/tr1/6_containers/array/comparison_operators/(equal.cc, greater.cc, greater_or_equal.cc, less.cc, less_or_equal.cc, not_equal): New. * testsuite/tr1/6_containers/array/cons/aggregate_initialization.cc: New. * testsuite/tr1/6_containers/array/element_access/at_out_of_range.cc: New. * testsuite/tr1/6_containers/array/iterators/end_is_one_past.cc: New. * testsuite/tr1/6_containers/array/requirements/(contiguous.cc, instantiate, typedefs, zero_size_arrays): New. Index: include/tr1/array =================================================================== RCS file: /cvs/gcc/gcc/libstdc++-v3/include/tr1/array,v retrieving revision 1.2 diff -c -p -r1.2 array *** include/tr1/array 16 Oct 2004 13:48:34 -0000 1.2 --- include/tr1/array 21 Oct 2004 18:41:43 -0000 *************** *** 32,37 **** --- 32,39 ---- #include #include + #include + #include //namespace std::tr1 namespace std *************** namespace tr1 *** 40,51 **** { // [6.2.2] Class template array template // Requires complete type _Tp. - // Use of char array allows _Tp to skirt default constructable requirement. template struct array { - enum { _S_index = _Nm }; - typedef _Tp value_type; typedef value_type& reference; typedef const value_type& const_reference; --- 42,50 ---- *************** namespace tr1 *** 56,62 **** typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; ! value_type _M_instance[_Nm]; // No explicit construct/copy/destroy for aggregate type. --- 55,65 ---- typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; ! // Compile time constant without other dependencies. ! enum { _S_index = _Nm }; ! ! // Support for zero-sized arrays mandatory. ! value_type _M_instance[_Nm ? _Nm : 1]; // No explicit construct/copy/destroy for aggregate type. *************** namespace tr1 *** 77,87 **** iterator end() ! { return reinterpret_cast(&_M_instance[_S_index - 1]); } const_iterator end() const ! { return reinterpret_cast(&_M_instance[_S_index - 1]); } reverse_iterator rbegin() --- 80,90 ---- iterator end() ! { return reinterpret_cast(&_M_instance[_Nm]); } const_iterator end() const ! { return reinterpret_cast(&_M_instance[_Nm]); } reverse_iterator rbegin() *************** namespace tr1 *** 101,117 **** // Capacity. size_type ! size() const { return _S_index; } size_type ! max_size() const ! { ! // XXX Not specified. Unnecessary, this is fixed-size. ! return _S_index; ! } bool ! empty() const; // Element access. reference --- 104,116 ---- // Capacity. size_type ! size() const { return _Nm; } size_type ! max_size() const { return _Nm; } bool ! empty() const { return size() == 0; } // Element access. reference *************** namespace tr1 *** 125,140 **** const_reference at(size_type __n) const { ! if (__builtin_expect(__n > _S_index, false)) ! throw std::bad_alloc(); return reinterpret_cast(_M_instance[__n]); } reference at(size_type __n) { ! if (__builtin_expect(__n > _S_index, false)) ! throw std::bad_alloc(); return reinterpret_cast(_M_instance[__n]); } --- 124,139 ---- const_reference at(size_type __n) const { ! if (__builtin_expect(__n > _Nm, false)) ! std::__throw_out_of_range("array::at"); return reinterpret_cast(_M_instance[__n]); } reference at(size_type __n) { ! if (__builtin_expect(__n > _Nm, false)) ! std::__throw_out_of_range("array::at"); return reinterpret_cast(_M_instance[__n]); } *************** namespace tr1 *** 161,167 **** template bool operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) ! { return false; } template bool --- 160,166 ---- template bool operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) ! { return std::equal(__one.begin(), __one.end(), __two.begin()); } template bool *************** namespace tr1 *** 170,192 **** template bool ! operator<(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) ! { return false; } template bool operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) ! { return false; } template bool operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) ! { return false; } template bool operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) ! { return false; } // [6.2.2.2] Specialized algorithms. template --- 169,194 ---- template bool ! operator<(const array<_Tp, _Nm>& a, const array<_Tp, _Nm>& b) ! { ! return std::lexicographical_compare(a.begin(), a.end(), ! b.begin(), b.end()); ! } template bool operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) ! { return __two < __one; } template bool operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) ! { return !(__one > __two); } template bool operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) ! { return !(__one < __two); } // [6.2.2.2] Specialized algorithms. template Index: testsuite/tr1/6_containers/array/capacity/empty.cc =================================================================== RCS file: testsuite/tr1/6_containers/array/capacity/empty.cc diff -N testsuite/tr1/6_containers/array/capacity/empty.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/tr1/6_containers/array/capacity/empty.cc 21 Oct 2004 18:41:44 -0000 *************** *** 0 **** --- 1,53 ---- + // 2004-10-20 Benjamin Kosnik + // + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + // + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + // + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // 6.2.2 Class template array + + #include + #include + + void + test01() + { + { + const size_t len = 5; + typedef std::tr1::array array_type; + bool test __attribute__((unused)) = true; + array_type a = { 0, 1, 2, 3, 4 }; + + VERIFY( a.empty() == false ); + } + + { + const size_t len = 0; + typedef std::tr1::array array_type; + bool test __attribute__((unused)) = true; + array_type a; + + VERIFY( a.empty() == true ); + } + } + + int main() + { + test01(); + return 0; + } + Index: testsuite/tr1/6_containers/array/capacity/max_size.cc =================================================================== RCS file: testsuite/tr1/6_containers/array/capacity/max_size.cc diff -N testsuite/tr1/6_containers/array/capacity/max_size.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/tr1/6_containers/array/capacity/max_size.cc 21 Oct 2004 18:41:44 -0000 *************** *** 0 **** --- 1,53 ---- + // 2004-10-20 Benjamin Kosnik + // + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + // + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + // + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // 6.2.2 Class template array + + #include + #include + + void + test01() + { + { + const size_t len = 5; + typedef std::tr1::array array_type; + bool test __attribute__((unused)) = true; + array_type a = { 0, 1, 2, 3, 4 }; + + VERIFY( a.size() == len ); + } + + { + const size_t len = 0; + typedef std::tr1::array array_type; + bool test __attribute__((unused)) = true; + array_type a; + + VERIFY( a.size() == len ); + } + } + + int main() + { + test01(); + return 0; + } + Index: testsuite/tr1/6_containers/array/capacity/size.cc =================================================================== RCS file: testsuite/tr1/6_containers/array/capacity/size.cc diff -N testsuite/tr1/6_containers/array/capacity/size.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/tr1/6_containers/array/capacity/size.cc 21 Oct 2004 18:41:44 -0000 *************** *** 0 **** --- 1,53 ---- + // 2004-10-20 Benjamin Kosnik + // + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + // + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + // + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // 6.2.2 Class template array + + #include + #include + + void + test01() + { + { + const size_t len = 5; + typedef std::tr1::array array_type; + bool test __attribute__((unused)) = true; + array_type a = { 0, 1, 2, 3, 4 }; + + VERIFY( a.size() == len ); + } + + { + const size_t len = 0; + typedef std::tr1::array array_type; + bool test __attribute__((unused)) = true; + array_type a; + + VERIFY( a.size() == len ); + } + } + + int main() + { + test01(); + return 0; + } + Index: testsuite/tr1/6_containers/array/comparison_operators/equal.cc =================================================================== RCS file: testsuite/tr1/6_containers/array/comparison_operators/equal.cc diff -N testsuite/tr1/6_containers/array/comparison_operators/equal.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/tr1/6_containers/array/comparison_operators/equal.cc 21 Oct 2004 18:41:44 -0000 *************** *** 0 **** --- 1,45 ---- + // 2004-10-20 Benjamin Kosnik + // + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + // + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + // + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // 6.2.2 Class template array + + #include + #include + + void + test01() + { + const size_t len = 5; + typedef std::tr1::array array_type; + bool test __attribute__((unused)) = true; + array_type a = { 0, 1, 2, 3, 4 }; + array_type b = { 0, 1, 2, 3, 4 }; + array_type c = { 0, 1, 2, 3 }; + + VERIFY( a == b ); + VERIFY( !(a == c) ); + } + + int main() + { + test01(); + return 0; + } + Index: testsuite/tr1/6_containers/array/comparison_operators/greater.cc =================================================================== RCS file: testsuite/tr1/6_containers/array/comparison_operators/greater.cc diff -N testsuite/tr1/6_containers/array/comparison_operators/greater.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/tr1/6_containers/array/comparison_operators/greater.cc 21 Oct 2004 18:41:44 -0000 *************** *** 0 **** --- 1,45 ---- + // 2004-10-20 Benjamin Kosnik + // + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + // + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + // + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // 6.2.2 Class template array + + #include + #include + + void + test01() + { + const size_t len = 5; + typedef std::tr1::array array_type; + bool test __attribute__((unused)) = true; + array_type a = { 0, 1, 2, 3, 4 }; + array_type b = { 0, 1, 2, 3, 4 }; + array_type c = { 0, 1, 2, 3, 7 }; + + VERIFY( !(a > b) ); + VERIFY( c > a ); + } + + int main() + { + test01(); + return 0; + } + Index: testsuite/tr1/6_containers/array/comparison_operators/greater_or_equal.cc =================================================================== RCS file: testsuite/tr1/6_containers/array/comparison_operators/greater_or_equal.cc diff -N testsuite/tr1/6_containers/array/comparison_operators/greater_or_equal.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/tr1/6_containers/array/comparison_operators/greater_or_equal.cc 21 Oct 2004 18:41:44 -0000 *************** *** 0 **** --- 1,45 ---- + // 2004-10-20 Benjamin Kosnik + // + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + // + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + // + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // 6.2.2 Class template array + + #include + #include + + void + test01() + { + const size_t len = 5; + typedef std::tr1::array array_type; + bool test __attribute__((unused)) = true; + array_type a = { 0, 1, 2, 3, 4 }; + array_type b = { 0, 1, 2, 3, 4 }; + array_type c = { 0, 1, 2, 3, 7 }; + + VERIFY( a >= b ); + VERIFY( c >= a ); + } + + int main() + { + test01(); + return 0; + } + Index: testsuite/tr1/6_containers/array/comparison_operators/less.cc =================================================================== RCS file: testsuite/tr1/6_containers/array/comparison_operators/less.cc diff -N testsuite/tr1/6_containers/array/comparison_operators/less.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/tr1/6_containers/array/comparison_operators/less.cc 21 Oct 2004 18:41:44 -0000 *************** *** 0 **** --- 1,45 ---- + // 2004-10-20 Benjamin Kosnik + // + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + // + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + // + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // 6.2.2 Class template array + + #include + #include + + void + test01() + { + const size_t len = 5; + typedef std::tr1::array array_type; + bool test __attribute__((unused)) = true; + array_type a = { 0, 1, 2, 3, 4 }; + array_type b = { 0, 1, 2, 3, 4 }; + array_type c = { 0, 1, 2, 3, 7 }; + + VERIFY( !(a < b) ); + VERIFY( a < c ); + } + + int main() + { + test01(); + return 0; + } + Index: testsuite/tr1/6_containers/array/comparison_operators/less_or_equal.cc =================================================================== RCS file: testsuite/tr1/6_containers/array/comparison_operators/less_or_equal.cc diff -N testsuite/tr1/6_containers/array/comparison_operators/less_or_equal.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/tr1/6_containers/array/comparison_operators/less_or_equal.cc 21 Oct 2004 18:41:44 -0000 *************** *** 0 **** --- 1,45 ---- + // 2004-10-20 Benjamin Kosnik + // + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + // + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + // + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // 6.2.2 Class template array + + #include + #include + + void + test01() + { + const size_t len = 5; + typedef std::tr1::array array_type; + bool test __attribute__((unused)) = true; + array_type a = { 0, 1, 2, 3, 4 }; + array_type b = { 0, 1, 2, 3, 4 }; + array_type c = { 0, 1, 2, 3, 7 }; + + VERIFY( a <= b ); + VERIFY( a <= c ); + } + + int main() + { + test01(); + return 0; + } + Index: testsuite/tr1/6_containers/array/comparison_operators/not_equal.cc =================================================================== RCS file: testsuite/tr1/6_containers/array/comparison_operators/not_equal.cc diff -N testsuite/tr1/6_containers/array/comparison_operators/not_equal.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/tr1/6_containers/array/comparison_operators/not_equal.cc 21 Oct 2004 18:41:44 -0000 *************** *** 0 **** --- 1,45 ---- + // 2004-10-20 Benjamin Kosnik + // + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + // + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + // + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // 6.2.2 Class template array + + #include + #include + + void + test01() + { + const size_t len = 5; + typedef std::tr1::array array_type; + bool test __attribute__((unused)) = true; + array_type a = { 0, 1, 2, 3, 4 }; + array_type b = { 0, 1, 2, 3, 4 }; + array_type c = { 0, 1, 2, 3 }; + + VERIFY( !(a != b) ); + VERIFY( a != c ); + } + + int main() + { + test01(); + return 0; + } + Index: testsuite/tr1/6_containers/array/cons/aggregate_initialization.cc =================================================================== RCS file: testsuite/tr1/6_containers/array/cons/aggregate_initialization.cc diff -N testsuite/tr1/6_containers/array/cons/aggregate_initialization.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/tr1/6_containers/array/cons/aggregate_initialization.cc 21 Oct 2004 18:41:44 -0000 *************** *** 0 **** --- 1,41 ---- + // { dg-do compile } + + // 2004-10-20 Benjamin Kosnik + // + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + // + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + // + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // 6.2.2 Class template array + + #include + + void + test01() + { + typedef std::tr1::array array_type; + + array_type a = { 0, 1, 2, 3, 4 }; + array_type b = { 0, 1, 2, 3 }; + } + + int main() + { + test01(); + return 0; + } + Index: testsuite/tr1/6_containers/array/element_access/at_out_of_range.cc =================================================================== RCS file: testsuite/tr1/6_containers/array/element_access/at_out_of_range.cc diff -N testsuite/tr1/6_containers/array/element_access/at_out_of_range.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/tr1/6_containers/array/element_access/at_out_of_range.cc 21 Oct 2004 18:41:44 -0000 *************** *** 0 **** --- 1,54 ---- + // 2004-10-20 Benjamin Kosnik + // + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + // + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + // + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // 6.2.2 Class template array + + #include + #include + + void + test01() + { + const size_t len = 5; + typedef std::tr1::array array_type; + bool test __attribute__((unused)) = true; + array_type a = { 0, 1, 2, 3, 4 }; + + try + { + a.at(len); + } + catch(std::out_of_range& obj) + { + // Expected. + } + catch(...) + { + // Failed. + throw; + } + } + + int main() + { + test01(); + return 0; + } + Index: testsuite/tr1/6_containers/array/iterators/end_is_one_past.cc =================================================================== RCS file: testsuite/tr1/6_containers/array/iterators/end_is_one_past.cc diff -N testsuite/tr1/6_containers/array/iterators/end_is_one_past.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/tr1/6_containers/array/iterators/end_is_one_past.cc 21 Oct 2004 18:41:44 -0000 *************** *** 0 **** --- 1,46 ---- + // 2004-10-20 Benjamin Kosnik + // + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + // + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + // + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // 6.2.2 Class template array + + #include + #include + #include + + void + test01() + { + const size_t len = 5; + typedef std::tr1::array array_type; + bool test __attribute__((unused)) = true; + array_type a = { 0, 1, 2, 3, 4 }; + + array_type::iterator b = a.begin(); + array_type::iterator e = a.end(); + + VERIFY( e != (b + a.size() - 1)); + } + + int main() + { + test01(); + return 0; + } + Index: testsuite/tr1/6_containers/array/requirements/contiguous.cc =================================================================== RCS file: testsuite/tr1/6_containers/array/requirements/contiguous.cc diff -N testsuite/tr1/6_containers/array/requirements/contiguous.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/tr1/6_containers/array/requirements/contiguous.cc 21 Oct 2004 18:41:44 -0000 *************** *** 0 **** --- 1,46 ---- + // 2004-10-20 Benjamin Kosnik + // + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + // + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + // + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // 6.2.2 Class template array + + #include + #include + + void + test01() + { + const size_t len = 5; + typedef std::tr1::array array_type; + bool test __attribute__((unused)) = true; + array_type a = { 0, 1, 2, 3, 4 }; + + // &a[n] == &a[0] + n for all 0 <= n < N. + for (size_t i = 0; i < len; ++i) + { + VERIFY( &a[i] == &a[0] + i ); + } + } + + int main() + { + test01(); + return 0; + } + Index: testsuite/tr1/6_containers/array/requirements/instantiate.cc =================================================================== RCS file: testsuite/tr1/6_containers/array/requirements/instantiate.cc diff -N testsuite/tr1/6_containers/array/requirements/instantiate.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/tr1/6_containers/array/requirements/instantiate.cc 21 Oct 2004 18:41:44 -0000 *************** *** 0 **** --- 1,36 ---- + // { dg-do compile } + + // 2004-10-20 Benjamin Kosnik + // + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // As a special exception, you may use this file as part of a free software + // library without restriction. Specifically, if other files instantiate + // templates or use macros or inline functions from this file, or you compile + // this file and link it with other files to produce an executable, this + // file does not by itself cause the resulting executable to be covered by + // the GNU General Public License. This exception does not however + // invalidate any other reasons why the executable file might be covered by + // the GNU General Public License. + + // 6.2.2 Class template array + + #include + + template class std::tr1::array; Index: testsuite/tr1/6_containers/array/requirements/typedefs.cc =================================================================== RCS file: testsuite/tr1/6_containers/array/requirements/typedefs.cc diff -N testsuite/tr1/6_containers/array/requirements/typedefs.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/tr1/6_containers/array/requirements/typedefs.cc 21 Oct 2004 18:41:44 -0000 *************** *** 0 **** --- 1,49 ---- + // { dg-do compile } + + // 2004-10-20 Benjamin Kosnik + // + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // As a special exception, you may use this file as part of a free software + // library without restriction. Specifically, if other files instantiate + // templates or use macros or inline functions from this file, or you compile + // this file and link it with other files to produce an executable, this + // file does not by itself cause the resulting executable to be covered by + // the GNU General Public License. This exception does not however + // invalidate any other reasons why the executable file might be covered by + // the GNU General Public License. + + // 6.2.2 Class template array + + #include + + void test01() + { + // Check for required typedefs + typedef std::tr1::array test_type; + typedef test_type::reference reference; + typedef test_type::const_reference const_reference; + typedef test_type::iterator iterator; + typedef test_type::const_iterator const_iterator; + typedef test_type::size_type size_type; + typedef test_type::difference_type difference_type; + typedef test_type::value_type value_type; + typedef test_type::reverse_iterator reverse_iterator; + typedef test_type::const_reverse_iterator const_reverse_iterator; + } Index: testsuite/tr1/6_containers/array/requirements/zero_sized_arrays.cc =================================================================== RCS file: testsuite/tr1/6_containers/array/requirements/zero_sized_arrays.cc diff -N testsuite/tr1/6_containers/array/requirements/zero_sized_arrays.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/tr1/6_containers/array/requirements/zero_sized_arrays.cc 21 Oct 2004 18:41:44 -0000 *************** *** 0 **** --- 1,61 ---- + // 2004-10-20 Benjamin Kosnik + // + // Copyright (C) 2004 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library is free + // software; you can redistribute it and/or modify it under the + // terms of the GNU General Public License as published by the + // Free Software Foundation; either version 2, or (at your option) + // any later version. + // + // This library is distributed in the hope that it will be useful, + // but WITHOUT ANY WARRANTY; without even the implied warranty of + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + // GNU General Public License for more details. + // + // You should have received a copy of the GNU General Public License along + // with this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // 6.2.2.4 Zero sized arrays + + #include + #include + + void + test01() + { + const size_t len = 0; + typedef std::tr1::array array_type; + bool test __attribute__((unused)) = true; + + // 1: ? + array_type a = { }; + + // 2 + array_type b; + + // 3 + // begin() == end() + VERIFY( b.begin() == b.end() ); + + // 4: ? + // begin() == end() == unique value. + { + typedef std::tr1::array array_type1; + typedef std::tr1::array array_type2; + array_type1 one; + array_type2 two; + void* v1 = one.begin(); + void* v2 = two.begin(); + VERIFY( v1 != v2 ); + } + } + + int main() + { + test01(); + return 0; + } +