1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 19:42:54 +02:00

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).

llvm-svn: 175723
This commit is contained in:
David Blaikie 2013-02-21 06:05:57 +00:00
parent 59bb2dbaf6
commit 6739305653
2 changed files with 11 additions and 1 deletions

View File

@ -86,7 +86,7 @@ public:
const T& getValue() const LLVM_LVALUE_FUNCTION { assert(hasVal); return *getPointer(); }
T& getValue() LLVM_LVALUE_FUNCTION { assert(hasVal); return *getPointer(); }
operator bool() const { return hasVal; }
LLVM_EXPLICIT operator bool() const { return hasVal; }
bool hasValue() const { return hasVal; }
const T* operator->() const { return getPointer(); }
T* operator->() { return getPointer(); }

View File

@ -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