Added support for user-defined string literals.

Added testcase cpp0x_userdefined_literals.i


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@11494 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Matevz Jekovec 2009-08-04 00:51:21 +00:00
commit 8a4efbc6d3
4 changed files with 53 additions and 2 deletions

View file

@ -410,7 +410,8 @@ CPP0X_TEST_CASES = \
cpp0x_strongly_typed_enumerations \
cpp0x_rvalue_reference \
cpp0x_variadic_templates \
cpp0x_alternate_function_syntax
cpp0x_alternate_function_syntax \
cpp0x_userdefined_literals
# 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

View file

@ -0,0 +1,24 @@
/* This testcase checks whether Swig correctly parses the user-defined literals
for the string introduced in C++0x. */
%module cpp0x_userdefined_literals
%inline %{
#include <iostream>
struct OutputType {
int val;
OutputType(int v) { v=val; }
};
struct TT {
OutputType operator << (const char * string_values, size_t num_chars) { return OutputType(100); }
OutputType operator "" (const char * string_values, size_t num_chars) { return OutputType(100); }
OutputType operator "" _mySuffix1(const char * string_values, size_t num_chars) { return OutputType(100); }
OutputType operator "" _mySuffix2(const wchar_t * string_values, size_t num_chars) { return OutputType(200); }
OutputType operator "" _mySuffix3(const char16_t * string_values, size_t num_chars) { return OutputType(300); }
OutputType operator "" _mySuffix4(const char32_t * string_values, size_t num_chars) { return OutputType(400); }
OutputType operator "" _mySuffix5(int value) /* cooked version - ie. atoi() of string */ { return OutputType(500); }
};
%}