PageRenderTime 39ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Swig | 95 lines | 68 code | 27 blank | 0 comment | 0 complexity | ab8049037543cb83317368917658dd2e MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module template_specialization_defarg
  2. %inline %{
  3. template <class A, class B = double>
  4. struct C
  5. {
  6. };
  7. template <class BB>
  8. struct C<int , BB>
  9. {
  10. int hi()
  11. {
  12. return 0;
  13. }
  14. C(int a)
  15. {
  16. }
  17. };
  18. template <class BB>
  19. struct C<double , BB>
  20. {
  21. int hello()
  22. {
  23. return 0;
  24. }
  25. C(double a)
  26. {
  27. }
  28. };
  29. template <class T>
  30. struct Alloc
  31. {
  32. };
  33. template <class T, class A = double >
  34. struct D
  35. {
  36. D(int){}
  37. };
  38. template <>
  39. struct D<double>
  40. {
  41. D(){}
  42. int foo() { return 0; }
  43. };
  44. template <class T, class A = Alloc<T> >
  45. struct Vector
  46. {
  47. Vector(int){}
  48. };
  49. template <>
  50. struct Vector<double>
  51. {
  52. Vector(){}
  53. int foo() { return 0; }
  54. };
  55. %}
  56. //
  57. // This works fine
  58. //
  59. %template(C_i) C<int, double>;
  60. //
  61. // This one fails
  62. //
  63. %template(C_dd) C<double,double>;
  64. %template(C_d) C<double>;
  65. %template(D_i) D<int>;
  66. %template(D_d) D<double>;
  67. %template(Vector_i) Vector<int>;
  68. %template(Vector_d) Vector<double, Alloc<double> >;