C++11 ref-qualifier support added
Fixes #1059 Methods with rvalue ref-qualifiers are ignored by default as it is not possible to have an rvalue temporary from the target language (which is needed to call the rvalue ref-qualified method). A warning 405 is shown mentioning the ignored rvalue ref-qualifier method which can be seen with the -Wextra option. cpp_refqualifier.i:15: Warning 405: Method with rvalue ref-qualifier ignored h() const &&. Usually rvalue and lvalue ref-qualifier overloaded methods are written - the lvalue method will then be wrapped.
This commit is contained in:
parent
11d1050803
commit
9e19fe7868
10 changed files with 145 additions and 18 deletions
|
|
@ -561,6 +561,7 @@ CPP11_TEST_CASES += \
|
|||
cpp11_noexcept \
|
||||
cpp11_null_pointer_constant \
|
||||
cpp11_raw_string_literals \
|
||||
cpp11_ref_qualifiers \
|
||||
cpp11_result_of \
|
||||
cpp11_rvalue_reference \
|
||||
cpp11_rvalue_reference2 \
|
||||
|
|
|
|||
16
Examples/test-suite/cpp11_ref_qualifiers.i
Normal file
16
Examples/test-suite/cpp11_ref_qualifiers.i
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
%module cpp11_ref_qualifiers
|
||||
|
||||
%inline %{
|
||||
class Host {
|
||||
public:
|
||||
void h1() & {}
|
||||
void h2() const & {}
|
||||
void h3() && {}
|
||||
void h4() const && {}
|
||||
|
||||
void h() & {}
|
||||
void h() const & {}
|
||||
void h() && {}
|
||||
void h() const && {}
|
||||
};
|
||||
%}
|
||||
18
Examples/test-suite/errors/cpp_refqualifier.i
Normal file
18
Examples/test-suite/errors/cpp_refqualifier.i
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
%module cpp_refqualifier
|
||||
|
||||
%ignore Host::h_ignored;
|
||||
|
||||
class Host {
|
||||
public:
|
||||
void h1() &;
|
||||
void h2() const &;
|
||||
void h3() &&;
|
||||
void h4() const &&;
|
||||
|
||||
void h() &;
|
||||
void h() const &;
|
||||
void h() &&;
|
||||
void h() const &&;
|
||||
|
||||
void h_ignored() &&;
|
||||
};
|
||||
6
Examples/test-suite/errors/cpp_refqualifier.stderr
Normal file
6
Examples/test-suite/errors/cpp_refqualifier.stderr
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
cpp_refqualifier.i:9: Warning 405: Method with rvalue ref-qualifier ignored h3() &&.
|
||||
cpp_refqualifier.i:10: Warning 405: Method with rvalue ref-qualifier ignored h4() const &&.
|
||||
cpp_refqualifier.i:14: Warning 405: Method with rvalue ref-qualifier ignored h() &&.
|
||||
cpp_refqualifier.i:15: Warning 405: Method with rvalue ref-qualifier ignored h() const &&.
|
||||
cpp_refqualifier.i:13: Warning 512: Overloaded method Host::h() const & ignored,
|
||||
cpp_refqualifier.i:12: Warning 512: using non-const method Host::h() & instead.
|
||||
22
Examples/test-suite/java/cpp11_ref_qualifiers_runme.java
Normal file
22
Examples/test-suite/java/cpp11_ref_qualifiers_runme.java
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
import cpp11_ref_qualifiers.*;
|
||||
|
||||
public class cpp11_ref_qualifiers_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("cpp11_ref_qualifiers");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
Host h = new Host();
|
||||
h.h1();
|
||||
h.h2();
|
||||
h.h();
|
||||
}
|
||||
}
|
||||
|
||||
6
Examples/test-suite/python/cpp11_ref_qualifiers_runme.py
Normal file
6
Examples/test-suite/python/cpp11_ref_qualifiers_runme.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import cpp11_ref_qualifiers
|
||||
|
||||
h = cpp11_ref_qualifiers.Host()
|
||||
h.h1()
|
||||
h.h2()
|
||||
h.h()
|
||||
Loading…
Add table
Add a link
Reference in a new issue