[llvm-commits] [PATCH] New compatibility macro: LLVM_LVALUE_FUNCTION
Jordan Rose
jordan_rose at apple.com
Wed Nov 28 15:59:42 PST 2012
Hi, all. I'm a committer up on the Clang side, but lately I've been working on an internal side project that gets to use C++11. I was trying to put a non-copyable type in an llvm::Optional, but I discovered that that's a problem when you want to conditionally move it somewhere else.
I'd like to add rvalue overrides to Optional::getValue, but of course you can't do that unless the regular const version is annotated with an ampersand. Does anyone object to adding a new Compiler.h macro that expands to '&' when rvalue references are supported? It would look like this:
const T& getValue() const LLVM_LVALUE_FUNCTION { … }
This isn't perfect, but it could also help alleviate the "returning an inner pointer of a temporary" mistake that we keep making, and which GCC keeps causing us to crash on:
const T *getInteriorPointer() const LLVM_LVALUE_FUNCTION;
#if LLVM_USE_RVALUE_REFERENCES
void getInteriorPointer() && LLVM_DELETED_FUNCTION;
#endif
Thanks,
Jordan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LLVM_LVALUE_FUNCTION.diff
Type: application/octet-stream
Size: 1695 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121128/f66c3377/attachment.obj>
More information about the llvm-commits
mailing list