diff options
author | David Blaikie <dblaikie@gmail.com> | 2013-02-21 06:05:57 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2013-02-21 06:05:57 +0000 |
commit | 2bbc19c1c6cd60b9c56750d7b03311c47a88b748 (patch) | |
tree | 5de494a806c5f04c35fc27e77040a30927e22b14 /include/llvm/Support/Compiler.h | |
parent | 214df4285a974c61450477cbcf5c4a196d574a6a (diff) |
Make Optional<T>'s operator bool 'explicit' in C++11
Provides a general way to add 'explicit' for conversion operators (a no-op when
compiling as C++98).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175723 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/Compiler.h')
-rw-r--r-- | include/llvm/Support/Compiler.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h index adc0ce2ab1..25f42a98e7 100644 --- a/include/llvm/Support/Compiler.h +++ b/include/llvm/Support/Compiler.h @@ -341,4 +341,14 @@ # define LLVM_IS_UNALIGNED_ACCESS_FAST 0 #endif +/// \macro LLVM_EXPLICIT +/// \brief Expands to explicit on compilers which support explicit conversion +/// operators. Otherwise expands to nothing. +#if (__has_feature(cxx_explicit_conversions) \ + || defined(__GXX_EXPERIMENTAL_CXX0X__)) +#define LLVM_EXPLICIT explicit +#else +#define LLVM_EXPLICIT +#endif + #endif |