Added cpp0x_result_of testcase.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@11534 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
65c09323fc
commit
2f3a18e49b
3 changed files with 24 additions and 1 deletions
|
|
@ -412,7 +412,8 @@ CPP0X_TEST_CASES = \
|
|||
cpp0x_variadic_templates \
|
||||
cpp0x_alternate_function_syntax \
|
||||
cpp0x_userdefined_literals \
|
||||
cpp0x_decltype
|
||||
cpp0x_decltype \
|
||||
cpp0x_result_of
|
||||
# cpp0x_template_typedefs # not supported by any compiler yet
|
||||
# cpp0x_hash_types # not fully implemented yet
|
||||
# cpp0x_constructors # not supported by any compiler yet
|
||||
|
|
|
|||
19
Examples/test-suite/cpp0x_result_of.i
Normal file
19
Examples/test-suite/cpp0x_result_of.i
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/* This testcase checks whether Swig correctly uses the new result_of class
|
||||
and its templating capabilities introduced in C++0x. */
|
||||
%module cpp0x_result_of
|
||||
|
||||
%inline %{
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
|
||||
double square(double x) {
|
||||
return (x * x);
|
||||
}
|
||||
|
||||
template<class Fun, class Arg>
|
||||
typename std::result_of<Fun(Arg)>::type test_result_impl(Fun fun, Arg arg) {
|
||||
return fun(arg);
|
||||
}
|
||||
%}
|
||||
|
||||
%template(test_result) test_result_impl<double(*)(double), double>;
|
||||
3
Examples/test-suite/python/cpp0x_result_of_runme.py
Normal file
3
Examples/test-suite/python/cpp0x_result_of_runme.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import cpp0x_result_of
|
||||
if cpp0x_result_of.test_result(cpp0x_result_of.square, 3.0) != 9.0:
|
||||
raise RuntimeError, "test_result(square, 3.0) is not 9.0."
|
||||
Loading…
Add table
Add a link
Reference in a new issue