Skip to content

Commit a5e67d9

Browse files
Add failing example of partial parametric inheritance
1 parent 0419ca7 commit a5e67d9

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

examples/parametric.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ struct TemplateType
4040
}
4141
};
4242

43+
template<typename T>
44+
struct PartialTemplate : public TemplateType<P2,T>
45+
{
46+
};
47+
4348
// Template containing a non-type parameter
4449
template<typename T, T I>
4550
struct NonTypeParam
@@ -82,6 +87,14 @@ struct WrapTemplateType
8287
}
8388
};
8489

90+
struct WrapPartialTemplateType
91+
{
92+
template<typename TypeWrapperT>
93+
void operator()(TypeWrapperT&&)
94+
{
95+
}
96+
};
97+
8598
struct WrapTemplateDefaultType
8699
{
87100
template<typename TypeWrapperT>
@@ -249,8 +262,11 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& types)
249262
types.add_type<P1>("P1");
250263
types.add_type<P2>("P2");
251264

252-
types.add_type<Parametric<TypeVar<1>, TypeVar<2>>>("TemplateType")
253-
.apply<TemplateType<P1,P2>, TemplateType<P2,P1>>(WrapTemplateType());
265+
auto template_type = types.add_type<Parametric<TypeVar<1>, TypeVar<2>>>("TemplateType");
266+
template_type.apply<TemplateType<P1,P2>, TemplateType<P2,P1>>(WrapTemplateType());
267+
268+
types.add_type<Parametric<TypeVar<2>>, ParameterList<P2, TypeVar<2>>>("PartialTemplate", template_type.dt())
269+
.apply<PartialTemplate<P1>, PartialTemplate<P2>>(WrapPartialTemplateType());
254270

255271
types.add_type<Parametric<TypeVar<1>>>("TemplateDefaultType")
256272
.apply<TemplateDefaultType<P1>, TemplateDefaultType<P2>>(WrapTemplateDefaultType());

0 commit comments

Comments
 (0)