10

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?

Morwenn
  • 21,684
  • 12
  • 93
  • 152
CouchDeveloper
  • 18,174
  • 3
  • 45
  • 67

1 Answers1

13

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)
Morwenn
  • 21,684
  • 12
  • 93
  • 152
  • 4
    The very next sentence is "This paper proposes Option 1, thus favoring specialization..." Where is the answer for why that option was _not_ chosen? – Lack Jun 26 '17 at 23:06
  • @Lack I don't know that much, but I can guess: committee vote, majority for option 2. – Morwenn Dec 10 '17 at 21:20