File: template_default_class_parms.i

package info (click to toggle)
renderdoc 1.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 79,584 kB
  • sloc: cpp: 491,671; ansic: 285,823; python: 12,617; java: 11,345; cs: 7,181; makefile: 6,703; yacc: 5,682; ruby: 4,648; perl: 3,461; php: 2,119; sh: 2,068; lisp: 1,835; tcl: 1,068; ml: 747; xml: 137
file content (79 lines) | stat: -rw-r--r-- 1,901 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
%module template_default_class_parms

%inline %{
namespace Space {
  struct SomeType {};
  struct AnotherType {};
  template<typename C, typename D = SomeType, typename E = int> class Bar {
  public:
    C CType;
    D DType;
    E EType;
    Bar(C c, D d, E e) {}
    C method(C c, D d, E e) { return c; }
  };
  template<typename T = SomeType> class Foo {
  public:
    T TType;
    Foo(T t) {}
    T method(T t) { return t; }
  };
  template<typename T = int> class ATemplate {};
}
%}

// Use defaults
%template(DefaultBar) Space::Bar<double>;
%template(DefaultFoo) Space::Foo<>;

// Don't use all defaults
%template(BarAnotherTypeBool) Space::Bar<Space::AnotherType, bool>;
%template(FooAnotherType) Space::Foo<Space::AnotherType>;

%template() Space::ATemplate<>;


// Github issue #280 segfault
%inline %{
namespace Teuchos {
  class Describable {};
}
namespace KokkosClassic {
  namespace DefaultNode {
    struct DefaultNodeType {};
  }
}

namespace Tpetra {
  template <class LocalOrdinal = int,
            class GlobalOrdinal = LocalOrdinal,
            class Node = KokkosClassic::DefaultNode::DefaultNodeType>
  class Map : public Teuchos::Describable {
  public:
    typedef LocalOrdinal local_ordinal_type;
    typedef GlobalOrdinal global_ordinal_type;
    typedef Node node_type;
    void test_func(LocalOrdinal, GlobalOrdinal, Node) {}
  };
}
%}

#ifdef SWIGJAVA
// Fixes still required for other languages
%template(MapDefaults) Tpetra::Map<>;
#endif

%inline %{
namespace Details {
  template < class LO = ::Tpetra::Map<>::local_ordinal_type,
            class GO = typename ::Tpetra::Map<LO>::global_ordinal_type,
            class NT = typename ::Tpetra::Map<LO, GO>::node_type >
  class Transfer : public Teuchos::Describable {
  public:
    void transfer_func(LO, GO, NT) {}
  };
}
%}

// Below is not resolving correctly yet
//%template(TransferDefaults) Details::Transfer<>;