D's limited template specialization abilities compared to C++
Peter Alexander
peter.alexander.au at gmail.com
Sat May 25 06:37:28 PDT 2013
On Saturday, 25 May 2013 at 12:43:42 UTC, Ahuzhgairl wrote:
> C++ example, works:
>
> template <class> struct A;
> template <template <class> class X, class Y> struct A<X<Y>> {};
>
> template <class> struct B;
>
> int main() {
> A<B<int>> a;
> }
As we've shown, you can do this in D. Instead of template
templates, you use alias.
> But the following does not work:
>
> struct Foo {};
> template <class> struct B { Foo x; }
>
> template <nontype P> struct A;
> template <auto M, auto C, nontype P> struct A<M C::*P> {}
>
> int main() {
> A<&B<int>::x> a;
> }
It's getting very hard to see what you're trying to do. I think
it would help if you used real C++ and D syntax instead of
inventing new syntax because I can't tell what you're trying to
achieve and what semantics you expect of it.
Please post a small example of real, working, compilable C++ that
shows what you want to do, and we'll show you how to do it in D
(assuming it is possible).
More information about the Digitalmars-d
mailing list