Questions tagged [template-aliases]

67 questions
11
votes
1 answer

Template aliases conflicting types. g++ compiles successfully while clang fails

I encountered a very strange compiler error. For some reason the posted code does compile properly with g++ (7.3.0) while clang (7.0.0) fails: ../TemplateAlias/main.cpp:64:9: error: no matching function for call to 'freeFunc' freeFunc(new…
srohmen
  • 223
  • 1
  • 9
10
votes
1 answer

How to emulate deduction guides for template aliases?

Consider the following: template struct my_array { T values[N]; }; We can provide deduction guides for my_array, something like template my_array (Ts ...) -> my_array,…
lisyarus
  • 15,025
  • 3
  • 43
  • 68
10
votes
1 answer

Template alias, Template specialization and Template Template parameters

I want to determine the underlying template of a template parameter by using a combination of a template alias and template specializations. The follwing code compiles fine on gcc 4.8, 6.2.1 but not on clang 3.5, 3.8. #include template…
10
votes
1 answer

Alias template, partial specialization and the invalid parameter type void

Consider the following code: template struct S; template struct S { }; template using Alias = S; int main() { S s; Alias
skypjack
  • 49,335
  • 19
  • 95
  • 187
10
votes
1 answer

Identity of template aliases

Let's consider a set of template aliases: template using foo = T*; template using bar = T*; template using buz = foo; template< templateclass TT > struct id {}; using id_foo = id; using id_bar =…
Nickolay Merkin
  • 2,673
  • 1
  • 16
  • 14
10
votes
1 answer

template template alias to a nested template?

Template aliases are very convenient in simplifying types like typename F ::type to just F , where T and type are types. I would like to do the same for templates like F ::map, i.e., simplify them to F , where T and map are template…
iavr
  • 7,547
  • 1
  • 18
  • 53
10
votes
1 answer

Another case where whitespace matters (maybe?)

Is this another case, where whitespace matters in C++, or is it a compiler bug? Is the following code syntactically correct? #include template using EnableIf = typename std::enable_if::type; template
TommiT
  • 609
  • 3
  • 9
10
votes
1 answer

Is substitution failure an error with dependent non-type template parameters?

Let's say I have these template aliases: enum class enabler {}; template using EnableIf = typename std::enable_if::type; template using DisableIf = typename std::enable_if::type; I…
R. Martinho Fernandes
  • 228,013
  • 71
  • 433
  • 510
9
votes
2 answers

C++11 template alias as template template argument leads to different type?

We have observed a strange behaviour in the compilation of the follwing source code: template class TT> struct X { }; template struct Y { }; template using Z = Y; int main() { X y; X z; z = y; // it…
craffael
  • 373
  • 1
  • 10
8
votes
1 answer

Why doesn't the alias template in function parameter match the nested type it refers to?

This code compiles template struct A { struct Inner {} inner; void foo(Inner in); }; template void A::foo(typename A::Inner in) { } int main() { A a; a.foo(a.inner); } And it won't if I change…
H.Wei
  • 103
  • 6
8
votes
1 answer

Is there a way to deduce alias templates to template template parameter while still preserving its property of being deduced context

After a while I discovered again a power of template template-parameters. See e.g. the following snippet: template