C++11 conversion operator example and docs added

This commit is contained in:
William S Fulton 2014-03-10 19:19:52 +00:00
commit 9a45a09aec
2 changed files with 27 additions and 7 deletions

View file

@ -3,6 +3,9 @@
*/
%module cpp11_explicit_conversion_operators
%warnfilter(SWIGWARN_LANG_IDENTIFIER) Testable::operator bool;
%rename(AsInteger) Testable::operator int;
%inline %{
class U {
@ -24,5 +27,15 @@ public:
int t;
};
struct Testable {
// explicit conversion operator
explicit operator bool() const {
return false;
}
explicit operator int() {
return 42;
}
};
%}