Skip to content

Commit 108307e

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

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

examples/parametric.cpp

Lines changed: 21 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>
@@ -239,6 +252,9 @@ namespace jlcxx
239252
template<typename T1> struct IsMirroredType<CppVector<T1>> : std::false_type { };
240253
template<typename T1, typename T2> struct IsMirroredType<CppVector2<T1,T2>> : std::false_type { };
241254

255+
template<typename T> struct IsMirroredType<PartialTemplate<T>> : std::false_type { };
256+
template<typename T> struct SuperType<PartialTemplate<T>> { typedef TemplateType<P2,T> type; };
257+
242258
} // namespace jlcxx
243259

244260
JLCXX_MODULE define_julia_module(jlcxx::Module& types)
@@ -249,8 +265,11 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& types)
249265
types.add_type<P1>("P1");
250266
types.add_type<P2>("P2");
251267

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

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

0 commit comments

Comments
 (0)