File tree Expand file tree Collapse file tree 2 files changed +15
-12
lines changed
test/Interop/Cxx/templates Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Original file line number Diff line number Diff line change 1
1
#ifndef TEST_INTEROP_CXX_TEMPLATES_INPUTS_TEMPLATE_TEMPLATE_PARAMETER_H
2
2
#define TEST_INTEROP_CXX_TEMPLATES_INPUTS_TEMPLATE_TEMPLATE_PARAMETER_H
3
3
4
- template <template <class > class V >
5
- struct Asdf {
6
- V<IntWrapper> i;
7
- };
8
-
9
4
struct IntWrapper {
10
5
int value;
11
6
int getValue () const { return value; }
12
7
};
13
8
14
- template <class T >
9
+ template <class T >
15
10
struct MagicWrapper {
16
11
T t;
17
12
int getValuePlusArg (int arg) const { return t.getValue () + arg; }
18
13
};
19
14
20
- typedef Asdf<MagicWrapper> Hohoho;
15
+ template <template <class > class V >
16
+ struct TemplatedMagicWrapper {
17
+ V<IntWrapper> i;
18
+ int getValuePlusTwiceTheArg (int arg) const { return i.getValuePlusArg (arg) + arg; }
19
+ };
20
+
21
+ typedef TemplatedMagicWrapper<MagicWrapper> TemplatedWrappedMagicInt;
22
+ typedef MagicWrapper<IntWrapper> WrappedMagicInt;
21
23
#endif // TEST_INTEROP_CXX_TEMPLATES_INPUTS_TEMPLATE_TEMPLATE_PARAMETER_H
Original file line number Diff line number Diff line change 2
2
//
3
3
// REQUIRES: executable_test
4
4
5
- import NonTypeParameter
5
+ import TemplateTemplateParameter
6
6
import StdlibUnittest
7
7
8
8
var TemplatesTestSuite = TestSuite ( " TemplatesTestSuite " )
9
9
10
10
TemplatesTestSuite . test ( " variadic-class-template " ) {
11
- let a = IntWrapper ( value: 42 )
12
- let hohoho = Hohoho ( )
13
- hohoho. i = a
11
+ let myInt = IntWrapper ( value: 42 )
12
+ var magicInt = WrappedMagicInt ( t: myInt)
13
+ var templatedWrappedMagicInt = TemplatedWrappedMagicInt ( i: magicInt)
14
+ expectEqual ( templatedWrappedMagicInt. getValuePlusTwiceTheArg ( 10 ) , 62 )
14
15
}
15
16
16
- runAllTests ( )
17
+ runAllTests ( )
You can’t perform that action at this time.
0 commit comments