[llvm] r194362 - Add LLVM_HAS_INITIALIZER_LISTS for upcoming C++11 support. Use it in ArrayRef
Pete Cooper
peter_cooper at apple.com
Sun Nov 10 19:58:00 PST 2013
Author: pete
Date: Sun Nov 10 21:58:00 2013
New Revision: 194362
URL: http://llvm.org/viewvc/llvm-project?rev=194362&view=rev
Log:
Add LLVM_HAS_INITIALIZER_LISTS for upcoming C++11 support. Use it in ArrayRef
Modified:
llvm/trunk/include/llvm/ADT/ArrayRef.h
llvm/trunk/include/llvm/Support/Compiler.h
Modified: llvm/trunk/include/llvm/ADT/ArrayRef.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ArrayRef.h?rev=194362&r1=194361&r2=194362&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/ArrayRef.h (original)
+++ llvm/trunk/include/llvm/ADT/ArrayRef.h Sun Nov 10 21:58:00 2013
@@ -83,6 +83,13 @@ namespace llvm {
/*implicit*/ LLVM_CONSTEXPR ArrayRef(const T (&Arr)[N])
: Data(Arr), Length(N) {}
+#if LLVM_HAS_INITIALIZER_LISTS
+ /// Construct an ArrayRef from a std::initializer_list.
+ /*implicit*/ ArrayRef(const std::initializer_list<T> &Vec)
+ : Data(Vec.begin() == Vec.end() ? (T*)0 : Vec.begin()),
+ Length(Vec.size()) {}
+#endif
+
/// @}
/// @name Simple Operations
/// @{
Modified: llvm/trunk/include/llvm/Support/Compiler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Compiler.h?rev=194362&r1=194361&r2=194362&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Compiler.h (original)
+++ llvm/trunk/include/llvm/Support/Compiler.h Sun Nov 10 21:58:00 2013
@@ -403,4 +403,13 @@
# define LLVM_ENUM_INT_TYPE(intty)
#endif
+/// \brief Does the compiler support generalized initializers (using braced
+/// lists and std::initializer_list).
+#if (__has_feature(cxx_generalized_initializers) \
+|| defined(__GXX_EXPERIMENTAL_CXX0X__))
+#define LLVM_HAS_INITIALIZER_LISTS 1
+#else
+#define LLVM_HAS_INITIALIZER_LISTS 0
+#endif
+
#endif
More information about the llvm-commits
mailing list