Added initial support for C++0x decltype().
Added testcase cpp0x_decltype. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@11525 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
8a4efbc6d3
commit
e2e9b04b3d
5 changed files with 58 additions and 3 deletions
|
|
@ -411,7 +411,8 @@ CPP0X_TEST_CASES = \
|
|||
cpp0x_rvalue_reference \
|
||||
cpp0x_variadic_templates \
|
||||
cpp0x_alternate_function_syntax \
|
||||
cpp0x_userdefined_literals
|
||||
cpp0x_userdefined_literals \
|
||||
cpp0x_decltype
|
||||
# cpp0x_hash_types # not fully implemented yet
|
||||
# cpp0x_lambda_functions # not supported by GCC or MSVC yet
|
||||
# cpp0x_null_pointer_constant # not supported by any compilers yet
|
||||
|
|
|
|||
19
Examples/test-suite/cpp0x_decltype.i
Normal file
19
Examples/test-suite/cpp0x_decltype.i
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/* This testcase checks whether Swig correctly uses the new 'decltype()'
|
||||
introduced in C++0x.
|
||||
*/
|
||||
%module cpp0x_decltype
|
||||
|
||||
%inline %{
|
||||
class A {
|
||||
public:
|
||||
int i;
|
||||
decltype(i) j;
|
||||
|
||||
auto foo( decltype(i) a ) -> decltype(i) {
|
||||
if (a==5)
|
||||
return 10;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
%}
|
||||
19
Examples/test-suite/python/cpp0x_decltype_runme.py
Normal file
19
Examples/test-suite/python/cpp0x_decltype_runme.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import cpp0x_decltype
|
||||
|
||||
a = cpp0x_decltype.A()
|
||||
a.i = 5
|
||||
if a.i != 5:
|
||||
raise RuntimeError, "Assignment to a.i failed."
|
||||
|
||||
a.j = 10
|
||||
if a.j != 10:
|
||||
raise RuntimeError, "Assignment to a.j failed."
|
||||
|
||||
b = a.foo(5)
|
||||
if b != 10:
|
||||
raise RuntimeError, "foo(5) should return 10."
|
||||
|
||||
b = a.foo(6)
|
||||
if b != 0:
|
||||
raise RuntimeError, "foo(6) should return 0."
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue