diff options
author | Pete Cooper <peter_cooper@apple.com> | 2013-11-11 03:58:00 +0000 |
---|---|---|
committer | Pete Cooper <peter_cooper@apple.com> | 2013-11-11 03:58:00 +0000 |
commit | 43ed63bc8310758d2a80deecb2e470f383ca5691 (patch) | |
tree | 97343178b5fad1ae9e2873ff0d5cc1f132a6d3e4 /include | |
parent | 65d1be119b1b5cb279815fe2e1a3b48f86606a3d (diff) | |
download | external_llvm-43ed63bc8310758d2a80deecb2e470f383ca5691.zip external_llvm-43ed63bc8310758d2a80deecb2e470f383ca5691.tar.gz external_llvm-43ed63bc8310758d2a80deecb2e470f383ca5691.tar.bz2 |
Add LLVM_HAS_INITIALIZER_LISTS for upcoming C++11 support. Use it in ArrayRef
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194362 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/ADT/ArrayRef.h | 7 | ||||
-rw-r--r-- | include/llvm/Support/Compiler.h | 9 |
2 files changed, 16 insertions, 0 deletions
diff --git a/include/llvm/ADT/ArrayRef.h b/include/llvm/ADT/ArrayRef.h index a0b6eff..61467e9 100644 --- a/include/llvm/ADT/ArrayRef.h +++ b/include/llvm/ADT/ArrayRef.h @@ -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 /// @{ diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h index 13920fc..5ce9abc 100644 --- a/include/llvm/Support/Compiler.h +++ b/include/llvm/Support/Compiler.h @@ -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 |