summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/tr1/4_metaprogramming
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2005-01-11 12:29:31 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2005-01-11 12:29:31 +0000
commit6cd0842066d30c9047f464385a217bdc091d3be2 (patch)
tree04eac163a1c3bea2e7c37ba3b5f1b292e8f9ea82 /libstdc++-v3/testsuite/tr1/4_metaprogramming
parent5724df299a6aea451dbbdfe81dc7e4b15a5df26f (diff)
downloadgcc-6cd0842066d30c9047f464385a217bdc091d3be2.tar.gz
2005-01-11 Paolo Carlini <pcarlini@suse.de>
* include/tr1/type_traits: Implement alignment_of and aligned_storage. * testsuite/tr1/4_metaprogramming/other_transformations/ aligned_storage/aligned_storage.cc: New. * testsuite/tr1/4_metaprogramming/other_transformations/ aligned_storage/typedefs.cc: Likewise. * testsuite/tr1/4_metaprogramming/type_properties/ alignment_of/alignment_of.cc: Likewise. * testsuite/tr1/4_metaprogramming/type_properties/ alignment_of/typedefs.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@93183 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/tr1/4_metaprogramming')
-rw-r--r--libstdc++-v3/testsuite/tr1/4_metaprogramming/other_transformations/aligned_storage/aligned_storage.cc63
-rw-r--r--libstdc++-v3/testsuite/tr1/4_metaprogramming/other_transformations/aligned_storage/typedefs.cc33
-rw-r--r--libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/alignment_of/alignment_of.cc45
-rw-r--r--libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/alignment_of/typedefs.cc36
4 files changed, 177 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/other_transformations/aligned_storage/aligned_storage.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/other_transformations/aligned_storage/aligned_storage.cc
new file mode 100644
index 00000000000..de04f979c57
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/other_transformations/aligned_storage/aligned_storage.cc
@@ -0,0 +1,63 @@
+// 2005-01-11 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.8 Other transformations
+
+#include <tr1/type_traits>
+#include <testsuite_hooks.h>
+#include <testsuite_tr1.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::tr1::aligned_storage;
+ using std::tr1::alignment_of;
+ using namespace __gnu_test;
+
+ const std::size_t align_c = alignment_of<char>::value;
+ VERIFY( (sizeof(aligned_storage<4, align_c>::type) >= 4) );
+ VERIFY( (__alignof__(aligned_storage<4, align_c>::type) == align_c) );
+
+ const std::size_t align_s = alignment_of<short>::value;
+ VERIFY( (sizeof(aligned_storage<1, align_s>::type) >= 1) );
+ VERIFY( (__alignof__(aligned_storage<1, align_s>::type) == align_s) );
+
+ const std::size_t align_i = alignment_of<int>::value;
+ VERIFY( (sizeof(aligned_storage<7, align_i>::type) >= 7) );
+ VERIFY( (__alignof__(aligned_storage<7, align_i>::type) == align_i) );
+
+ const std::size_t align_d = alignment_of<double>::value;
+ VERIFY( (sizeof(aligned_storage<2, align_d>::type) >= 2) );
+ VERIFY( (__alignof__(aligned_storage<2, align_d>::type) == align_d) );
+
+ const std::size_t align_ai = alignment_of<int[4]>::value;
+ VERIFY( (sizeof(aligned_storage<20, align_ai>::type) >= 20) );
+ VERIFY( (__alignof__(aligned_storage<20, align_ai>::type) == align_ai) );
+
+ const std::size_t align_ct = alignment_of<ClassType>::value;
+ VERIFY( (sizeof(aligned_storage<11, align_ct>::type) >= 11) );
+ VERIFY( (__alignof__(aligned_storage<11, align_ct>::type) == align_ct) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/other_transformations/aligned_storage/typedefs.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/other_transformations/aligned_storage/typedefs.cc
new file mode 100644
index 00000000000..d6b42fb2082
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/other_transformations/aligned_storage/typedefs.cc
@@ -0,0 +1,33 @@
+// 2005-01-11 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::aligned_storage<1, 1> test_type;
+ typedef test_type::type type;
+}
diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/alignment_of/alignment_of.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/alignment_of/alignment_of.cc
new file mode 100644
index 00000000000..b10fd3350c3
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/alignment_of/alignment_of.cc
@@ -0,0 +1,45 @@
+// 2005-01-11 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::alignment_of;
+ using namespace __gnu_test;
+
+ VERIFY( (test_property<alignment_of, char>(__alignof__(char))) );
+ VERIFY( (test_property<alignment_of, short>(__alignof__(short))) );
+ VERIFY( (test_property<alignment_of, int>(__alignof__(int))) );
+ VERIFY( (test_property<alignment_of, double>(__alignof__(double))) );
+ VERIFY( (test_property<alignment_of, int[4]>(__alignof__(int[4]))) );
+ VERIFY( (test_property<alignment_of, ClassType>(__alignof__(ClassType))) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/alignment_of/typedefs.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/alignment_of/typedefs.cc
new file mode 100644
index 00000000000..01c193a994a
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/alignment_of/typedefs.cc
@@ -0,0 +1,36 @@
+// 2005-01-11 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::alignment_of<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;
+}