Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Partial Specialization of Alias Templates

Partial specializations of alias templates are not permitted:

For example, trying to be creative, yields this error in clang:

template <typename T>
using unwrapped_future_t = T;

template <typename T>
using unwrapped_future_t<future<T>> = typename future<T>::value_type;
                        ^~~~~~~~~~~
> error: partial specialization of alias templates is not permitted

Why is this not permitted?

like image 252
CouchDeveloper Avatar asked Feb 14 '14 08:02

CouchDeveloper


1 Answers

You can find the answer in the original proposal of alias templates:

2.2 The Main Choice: Specialization vs. Everything Else

After discussion on the reflectors and in the Evolution WG, it turns out that we have to choose between two mutually exclusive models:

  1. A typedef template is not itself an alias; only the (possibly-specialized) instantiations of the typedef template are aliases. This choice allows us to have specialization of typedef templates.

  2. A typedef template is itself an alias; it cannot be specialized. This choice would allow:

    • deduction on typedef template function parameters (see 2.4)
    • a declaration expressed using typedef templates be the same as the declaration without typedef templates (see 2.5)
    • typedef templates to match template template parameters (see 2.6)
like image 187
Morwenn Avatar answered Sep 19 '22 07:09

Morwenn