+2005-01-24 Paolo Carlini <pcarlini@suse.de>
+
+ * include/tr1/type_traits: Implement is_signed and is_unsigned.
+ * testsuite/tr1/4_metaprogramming/type_properties/
+ is_signed/is_signed.cc: New.
+ * testsuite/tr1/4_metaprogramming/type_properties/
+ is_signed/typedefs.cc: Likewise.
+ * testsuite/tr1/4_metaprogramming/type_properties/
+ is_unsigned/is_unsigned.cc: Likewise.
+ * testsuite/tr1/4_metaprogramming/type_properties/
+ is_unsigned/typedefs.cc: Likewise.
+
2005-01-23 Paolo Carlini <pcarlini@suse.de>
* docs/html/ext/lwg-active.html, lwg-defects.html: Import Revision 34.
struct has_virtual_destructor
: public false_type { };
+ template<typename>
+ struct is_signed
+ : public false_type { };
+ _DEFINE_SPEC(0, is_signed, signed char, true)
+ _DEFINE_SPEC(0, is_signed, short, true)
+ _DEFINE_SPEC(0, is_signed, int, true)
+ _DEFINE_SPEC(0, is_signed, long, true)
+ _DEFINE_SPEC(0, is_signed, long long, true)
+
+ template<typename>
+ struct is_unsigned
+ : public false_type { };
+ _DEFINE_SPEC(0, is_unsigned, unsigned char, true)
+ _DEFINE_SPEC(0, is_unsigned, unsigned short, true)
+ _DEFINE_SPEC(0, is_unsigned, unsigned int, true)
+ _DEFINE_SPEC(0, is_unsigned, unsigned long, true)
+ _DEFINE_SPEC(0, is_unsigned, unsigned long long, true)
+
template<typename _Tp>
struct alignment_of
: public integral_constant<std::size_t, __alignof__(_Tp)> { };
--- /dev/null
+// 2005-01-24 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2005 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 <tr1/type_traits>
+#include <testsuite_hooks.h>
+#include <testsuite_tr1.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::tr1::is_signed;
+ using namespace __gnu_test;
+
+ VERIFY( (test_category<is_signed, void>(false)) );
+
+ VERIFY( (test_category<is_signed, char>(false)) );
+ VERIFY( (test_category<is_signed, signed char>(true)) );
+ VERIFY( (test_category<is_signed, unsigned char>(false)) );
+#ifdef _GLIBCXX_USE_WCHAR_T
+ VERIFY( (test_category<is_signed, wchar_t>(false)) );
+#endif
+ VERIFY( (test_category<is_signed, short>(true)) );
+ VERIFY( (test_category<is_signed, unsigned short>(false)) );
+ VERIFY( (test_category<is_signed, int>(true)) );
+ VERIFY( (test_category<is_signed, unsigned int>(false)) );
+ VERIFY( (test_category<is_signed, long>(true)) );
+ VERIFY( (test_category<is_signed, unsigned long>(false)) );
+ VERIFY( (test_category<is_signed, long long>(true)) );
+ VERIFY( (test_category<is_signed, unsigned long long>(false)) );
+
+ VERIFY( (test_category<is_signed, float>(false)) );
+ VERIFY( (test_category<is_signed, double>(false)) );
+ VERIFY( (test_category<is_signed, long double>(false)) );
+
+ // Sanity check.
+ VERIFY( (test_category<is_signed, ClassType>(false)) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2005-01-24 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2005 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 <tr1/type_traits>
+
+// { dg-do compile }
+
+void test01()
+{
+ // Check for required typedefs
+ typedef std::tr1::is_signed<int> 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;
+}
--- /dev/null
+// 2005-01-24 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2005 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 <tr1/type_traits>
+#include <testsuite_hooks.h>
+#include <testsuite_tr1.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::tr1::is_unsigned;
+ using namespace __gnu_test;
+
+ VERIFY( (test_category<is_unsigned, void>(false)) );
+
+ VERIFY( (test_category<is_unsigned, char>(false)) );
+ VERIFY( (test_category<is_unsigned, signed char>(false)) );
+ VERIFY( (test_category<is_unsigned, unsigned char>(true)) );
+#ifdef _GLIBCXX_USE_WCHAR_T
+ VERIFY( (test_category<is_unsigned, wchar_t>(false)) );
+#endif
+ VERIFY( (test_category<is_unsigned, short>(false)) );
+ VERIFY( (test_category<is_unsigned, unsigned short>(true)) );
+ VERIFY( (test_category<is_unsigned, int>(false)) );
+ VERIFY( (test_category<is_unsigned, unsigned int>(true)) );
+ VERIFY( (test_category<is_unsigned, long>(false)) );
+ VERIFY( (test_category<is_unsigned, unsigned long>(true)) );
+ VERIFY( (test_category<is_unsigned, long long>(false)) );
+ VERIFY( (test_category<is_unsigned, unsigned long long>(true)) );
+
+ VERIFY( (test_category<is_unsigned, float>(false)) );
+ VERIFY( (test_category<is_unsigned, double>(false)) );
+ VERIFY( (test_category<is_unsigned, long double>(false)) );
+
+ // Sanity check.
+ VERIFY( (test_category<is_unsigned, ClassType>(false)) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2005-01-24 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2005 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 <tr1/type_traits>
+
+// { dg-do compile }
+
+void test01()
+{
+ // Check for required typedefs
+ typedef std::tr1::is_unsigned<int> 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;
+}