/trunk/Examples/test-suite/template_specialization.i

# · Swig · 37 lines · 26 code · 11 blank · 0 comment · 0 complexity · 9cb76bf5bdcc74ef110cce9447e02ea1 MD5 · raw file

  1. %module template_specialization
  2. %rename(not1) *::operator!() const;
  3. %rename(negate) *::operator-() const;
  4. %inline %{
  5. namespace vfncs {
  6. template <class ArgType>
  7. struct UnaryFunction
  8. {
  9. UnaryFunction operator-() const { return *this; }
  10. };
  11. template <>
  12. struct UnaryFunction<bool>
  13. {
  14. // This works
  15. // UnaryFunction<bool> operator!() const;
  16. // This doesn't
  17. UnaryFunction operator!() const { return *this; }
  18. // Does this?
  19. void foo(UnaryFunction) { }
  20. };
  21. }
  22. %}
  23. namespace vfncs {
  24. %template(UnaryFunction_double) UnaryFunction<double>;
  25. %template(UnaryFunction_bool) UnaryFunction<bool>;
  26. }