Disallow using RAIIdmem::operator T* on rvalues

This commit is contained in:
Kp 2014-09-07 21:54:30 +00:00
parent 7d166a70e0
commit 0387a2c771
2 changed files with 19 additions and 0 deletions

View file

@ -747,6 +747,20 @@ int main(int, char **){
if self.Cxx11Compile(context, text=text, msg='for C++11 template aliases'):
context.sconf.Define('DXX_HAVE_CXX11_TEMPLATE_ALIAS')
@_custom_test
def check_cxx11_ref_qualifier(self,context):
text = '''
struct A {
int a()&{return 1;}
int a()&&{return 2;}
};
int main(int, char **){
A a;
return a.a() != A().a();
}
'''
if self.Cxx11Compile(context, text=text, msg='for C++11 reference qualified methods'):
context.sconf.Define('DXX_HAVE_CXX11_REF_QUALIFIER')
@_custom_test
def check_deep_tuple(self,context):
text = '''
#include <tuple>

View file

@ -111,7 +111,12 @@ struct RAIIdmem : BaseRAIIdmem
RAIIdmem() = default;
RAIIdmem(std::nullptr_t) : BaseRAIIdmem(nullptr) {}
explicit RAIIdmem(T *v) : BaseRAIIdmem(v) {}
#ifdef DXX_HAVE_CXX11_REF_QUALIFIER
operator T*() const & { return static_cast<T*>(p); }
operator T*() const && = delete;
#else
operator T*() const { return static_cast<T*>(p); }
#endif
T *operator->() const { return static_cast<T*>(p); }
};