diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index b79cee21fd0..7a41704fb81 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2004-12-12 Paolo Carlini + + * include/tr1/type_traits: Implement extent. + * testsuite/tr1/4_metaprogramming/type_properties/extent/ + extent.cc: New. + * testsuite/tr1/4_metaprogramming/type_properties/extent/ + typedefs.cc: Likewise. + 2004-12-12 Paolo Carlini * include/tr1/type_traits: Implement is_pointer, remove_pointer, diff --git a/libstdc++-v3/include/tr1/type_traits b/libstdc++-v3/include/tr1/type_traits index 6fef185b5b3..f38f51e858d 100644 --- a/libstdc++-v3/include/tr1/type_traits +++ b/libstdc++-v3/include/tr1/type_traits @@ -244,8 +244,21 @@ namespace tr1 struct rank<_Tp[]> : public integral_constant::value> { }; - template - struct extent; + template + struct extent + : integral_constant { }; + + template + struct extent<_Tp[_Size], _Uint> + : integral_constant::value> + { }; + + template + struct extent<_Tp[], _Uint> + : integral_constant::value> + { }; /// @brief relationships between types [4.6]. template diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/extent/extent.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/extent/extent.cc new file mode 100644 index 00000000000..a5891aa059a --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/extent/extent.cc @@ -0,0 +1,57 @@ +// 2004-12-12 Paolo Carlini +// +// 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. + +// 4.5.3 Type properties + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::tr1::extent; + using namespace __gnu_test; + + VERIFY( (test_property(0)) ); + VERIFY( (test_property(2)) ); + VERIFY( (test_property(2)) ); + VERIFY( (test_property(0)) ); + VERIFY( (extent::value == 0) ); + VERIFY( (extent::value == 0) ); + VERIFY( (extent::value == 4) ); + VERIFY( (extent::value == 4) ); + VERIFY( (extent::value == 12) ); + VERIFY( (test_property(0)) ); + VERIFY( (test_property(2)) ); + VERIFY( (test_property(2)) ); + VERIFY( (test_property(0)) ); + VERIFY( (extent::value == 0) ); + VERIFY( (extent::value == 0) ); + VERIFY( (extent::value == 4) ); + VERIFY( (extent::value == 4) ); + VERIFY( (extent::value == 12) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/extent/typedefs.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/extent/typedefs.cc new file mode 100644 index 00000000000..02a468c5821 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/extent/typedefs.cc @@ -0,0 +1,36 @@ +// 2004-12-11 Paolo Carlini +// +// 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. + +// +// NB: This file is for testing tr1/type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::tr1::extent test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +}