C++11 conversion operator example and docs added
This commit is contained in:
parent
adc3cfeb57
commit
9a45a09aec
2 changed files with 27 additions and 7 deletions
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue