Update on C++11 user-defined literal status
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@13850 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
e25da884cb
commit
dd18423e76
2 changed files with 45 additions and 12 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/* This testcase checks whether SWIG correctly parses the user-defined literals
|
||||
for the string introduced in C++0x. */
|
||||
introduced in C++0x. */
|
||||
%module cpp0x_userdefined_literals
|
||||
|
||||
%inline %{
|
||||
|
|
@ -7,18 +7,20 @@
|
|||
|
||||
struct OutputType {
|
||||
int val;
|
||||
|
||||
OutputType(int v) { v=val; }
|
||||
OutputType(int v) : val(v) {}
|
||||
};
|
||||
|
||||
/* Note: GCC doesn't support user-defined literals yet! */
|
||||
struct TT {
|
||||
OutputType operator "" (const char * string_values, size_t num_chars) { return OutputType(100); }
|
||||
// Raw literal
|
||||
OutputType operator "" _myRawLiteral(const char * value) { return OutputType(10); }
|
||||
|
||||
// Cooked numeric literals
|
||||
OutputType operator "" _mySuffixIntegral(unsigned long long) { return OutputType(20); }
|
||||
OutputType operator "" _mySuffixFloat(long double) { return OutputType(30); }
|
||||
|
||||
// Cooked string literals
|
||||
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); }
|
||||
};
|
||||
|
||||
%}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue