aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@redhat.com>2009-05-27 21:17:49 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2009-05-27 21:17:49 +0000
commiteaf4cf4fdcd9bcf19bcb96b2a49e42f91f4d082a (patch)
tree95dccbcc2cae5ca8bbfb79669d2406a54d272f82
parent626e0599af96df36ac6b847349a33948d7bb3f7e (diff)
downloadgcc-eaf4cf4fdcd9bcf19bcb96b2a49e42f91f4d082a.zip
gcc-eaf4cf4fdcd9bcf19bcb96b2a49e42f91f4d082a.tar.gz
gcc-eaf4cf4fdcd9bcf19bcb96b2a49e42f91f4d082a.tar.bz2
initializer_list: Format.
2009-05-27 Benjamin Kosnik <bkoz@redhat.com> * libsupc++/initializer_list: Format. * testsuite/18_support/initializer_list/requirements/typedefs.cc: New. * testsuite/18_support/initializer_list/requirements/ explicit_instantiation.cc: New. From-SVN: r147931
-rw-r--r--libstdc++-v3/ChangeLog9
-rw-r--r--libstdc++-v3/libsupc++/initializer_list51
-rw-r--r--libstdc++-v3/testsuite/18_support/initializer_list/requirements/explicit_instantiation.cc24
-rw-r--r--libstdc++-v3/testsuite/18_support/initializer_list/requirements/typedefs.cc34
4 files changed, 91 insertions, 27 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 1f7be0f..c7011b0 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,7 +1,14 @@
2009-05-27 Benjamin Kosnik <bkoz@redhat.com>
+ * libsupc++/initializer_list: Format.
+ * testsuite/18_support/initializer_list/requirements/typedefs.cc: New.
+ * testsuite/18_support/initializer_list/requirements/
+ explicit_instantiation.cc: New.
+
+2009-05-27 Benjamin Kosnik <bkoz@redhat.com>
+
PR libstdc++/40273
- * include/tr1_impl/functional: Add explicit cast.
+ * include/tr1_impl/functional: Add explicit casts.
* testsuite/20_util/function/requirements/
explicit_instantiation.cc: New.
* testsuite/20_util/function/null_pointer_comparisons.cc: New.
diff --git a/libstdc++-v3/libsupc++/initializer_list b/libstdc++-v3/libsupc++/initializer_list
index 4a48cc5..20e2900 100644
--- a/libstdc++-v3/libsupc++/initializer_list
+++ b/libstdc++-v3/libsupc++/initializer_list
@@ -8,12 +8,12 @@
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
-//
+//
// GCC 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.
-//
+//
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
@@ -27,8 +27,8 @@
* This is a Standard C++ Library header.
*/
-#ifndef __CXX_INITIALIZER_LIST
-#define __CXX_INITIALIZER_LIST
+#ifndef _INITIALIZER_LIST
+#define _INITIALIZER_LIST
#ifdef __GXX_EXPERIMENTAL_CXX0X__
@@ -42,40 +42,39 @@ namespace std
template<class _E>
class initializer_list
{
- const _E* __array;
- size_t __len;
-
- // The compiler can call a private constructor.
- initializer_list(const _E* __a, size_t __l)
- : __array(__a), __len(__l) { }
-
public:
+ typedef _E value_type;
+ typedef const _E& reference;
+ typedef const _E& const_reference;
+ typedef size_t size_type;
+ typedef const _E* iterator;
+ typedef const _E* const_iterator;
- typedef _E value_type;
- typedef const _E& reference;
- typedef const _E& const_reference;
- typedef size_t size_type;
+ private:
+ iterator _M_array;
+ size_type _M_len;
- typedef const _E* iterator;
- typedef const _E* const_iterator;
+ // The compiler can call a private constructor.
+ initializer_list(const_iterator __a, size_type __l)
+ : _M_array(__a), _M_len(__l) { }
- initializer_list()
- : __array(NULL), __len(0) { }
+ public:
+ initializer_list() : _M_array(NULL), _M_len(0) { }
// Number of elements.
- size_t size() const
- { return __len; }
+ size_type
+ size() const { return _M_len; }
// First element.
- const _E* begin() const
- { return __array; }
+ const_iterator
+ begin() const { return _M_array; }
// One past the last element.
- const _E* end() const
- { return begin() + size(); }
+ const_iterator
+ end() const { return begin() + size(); }
};
}
#pragma GCC visibility pop
#endif // C++0x
-#endif // __CXX_INITIALIZER_LIST
+#endif // _INITIALIZER_LIST
diff --git a/libstdc++-v3/testsuite/18_support/initializer_list/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/18_support/initializer_list/requirements/explicit_instantiation.cc
new file mode 100644
index 0000000..651ec0e
--- /dev/null
+++ b/libstdc++-v3/testsuite/18_support/initializer_list/requirements/explicit_instantiation.cc
@@ -0,0 +1,24 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// 2009-05-27 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <initializer_list>
+
+template class std::initializer_list<int>;
diff --git a/libstdc++-v3/testsuite/18_support/initializer_list/requirements/typedefs.cc b/libstdc++-v3/testsuite/18_support/initializer_list/requirements/typedefs.cc
new file mode 100644
index 0000000..1f99392
--- /dev/null
+++ b/libstdc++-v3/testsuite/18_support/initializer_list/requirements/typedefs.cc
@@ -0,0 +1,34 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// 2009-05-27 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <initializer_list>
+
+void test01()
+{
+ // Check for required typedefs
+ typedef std::initializer_list<int> test_type;
+ typedef test_type::value_type type1;
+ typedef test_type::size_type type2;
+ typedef test_type::reference type3;
+ typedef test_type::const_reference type4;
+ typedef test_type::iterator type5;
+ typedef test_type::const_iterator type5;
+}