[cfe-commits] [libcxx] r104975 - in /libcxx/trunk: include/initializer_list test/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp

Howard Hinnant hhinnant at apple.com
Fri May 28 10:53:59 PDT 2010


Author: hhinnant
Date: Fri May 28 12:53:59 2010
New Revision: 104975

URL: http://llvm.org/viewvc/llvm-project?rev=104975&view=rev
Log:
[support.initlist.range]

Added:
    libcxx/trunk/test/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp
Modified:
    libcxx/trunk/include/initializer_list

Modified: libcxx/trunk/include/initializer_list
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/initializer_list?rev=104975&r1=104974&r2=104975&view=diff
==============================================================================
--- libcxx/trunk/include/initializer_list (original)
+++ libcxx/trunk/include/initializer_list Fri May 28 12:53:59 2010
@@ -36,6 +36,9 @@
     const E* end()   const;
 };
 
+template<class E> const E* begin(initializer_list<E> il);
+template<class E> const E* end(initializer_list<E> il);
+
 }  // std
 
 */
@@ -75,6 +78,22 @@
     _LIBCPP_ALWAYS_INLINE const _E* end()   const {return __begin_ + __size_;}
 };
 
+template<class _E>
+inline _LIBCPP_INLINE_VISIBILITY
+const _E*
+begin(initializer_list<_E> __il)
+{
+    return __il.begin();
+}
+
+template<class _E>
+inline _LIBCPP_INLINE_VISIBILITY
+const _E*
+end(initializer_list<_E> __il)
+{
+    return __il.end();
+}
+
 }  // std
 
 #endif  // _LIBCPP_INITIALIZER_LIST

Added: libcxx/trunk/test/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp?rev=104975&view=auto
==============================================================================
--- libcxx/trunk/test/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp (added)
+++ libcxx/trunk/test/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp Fri May 28 12:53:59 2010
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <initializer_list>
+
+// template<class E> const E* begin(initializer_list<E> il);
+
+#include <initializer_list>
+#include <cassert>
+
+struct A
+{
+    A(std::initializer_list<int> il)
+    {
+        const int* b = begin(il);
+        const int* e = end(il);
+        assert(il.size() == 3);
+        assert(e - b == il.size());
+        assert(*b++ == 3);
+        assert(*b++ == 2);
+        assert(*b++ == 1);
+    }
+};
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    A test1 = {3, 2, 1};
+#endif
+}





More information about the cfe-commits mailing list