This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH to implement initializer lists proposal (n2672)
Hi,
On Thu, Jul 3, 2008 at 6:32 AM, Jason Merrill <jason@redhat.com> wrote:
Here's a patch to address the issues people brought up:
Tested x86_64-pc-linux-gnu, applied to trunk.
All C++ tests in our nightly tester now fail with
Committed the below to unbreak, header just not installed, AFAICS.
Jason, two small additional suggestions:
1- In general, careful with single _ + single capital names: many
examples in the list of badnames (luckily not _E, I think...)
2- In general, when we add C++0x facilities to the containers we try to
also enable the corresponding debug-mode versions, often it's just a
matter of adding the declaration and forward...
Thanks again,
Paolo.
//////////////////
2008-07-03 Paolo Carlini <paolo.carlini@oracle.com>
* libsupc++/Makefile.am: Add initializer_list to the headers.
* libsupc++/Makefile.in: Regenerate.
* libsupc++/initializer_list: Minor cosmetic changes.
Index: libsupc++/Makefile.am
===================================================================
--- libsupc++/Makefile.am (revision 137408)
+++ libsupc++/Makefile.am (working copy)
@@ -1,6 +1,6 @@
## Makefile for the GNU C++ Support library.
##
-## Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007
+## Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
## Free Software Foundation, Inc.
##
## Process this file with automake to produce Makefile.in.
@@ -33,7 +33,8 @@
headers = \
- exception new typeinfo cxxabi.h cxxabi-forced.h exception_defines.h
+ exception new typeinfo cxxabi.h cxxabi-forced.h exception_defines.h \
+ initializer_list
if GLIBCXX_HOSTED
c_sources = \
Index: libsupc++/initializer_list
===================================================================
--- libsupc++/initializer_list (revision 137408)
+++ libsupc++/initializer_list (working copy)
@@ -40,25 +40,30 @@
namespace std
{
template<class _E>
- class initializer_list
- {
- const _E* __array;
- size_t __len;
+ class initializer_list
+ {
+ const _E* __array;
+ size_t __len;
- // The compiler can call a private constructor.
- initializer_list(const _E* __a, size_t __l)
+ // The compiler can call a private constructor.
+ initializer_list(const _E* __a, size_t __l)
: __array(__a), __len(__l) { }
- public:
- initializer_list()
- : __array(NULL), __len(0) {}
-
- size_t size() const // number of elements
- { return __len; }
- const _E* begin() const // first element
- { return __array; }
- const _E* end() const // one past the last element
- { return begin() + size(); }
+ public:
+ initializer_list()
+ : __array(NULL), __len(0) { }
+
+ // Number of elements.
+ size_t size() const
+ { return __len; }
+
+ // First element.
+ const _E* begin() const
+ { return __array; }
+
+ // One past the last element.
+ const _E* end() const
+ { return begin() + size(); }
};
}