samedi 25 avril 2015

Can a forwarding reference be aliased with an alias template?


This is a continuation of my previous question:

Can an identity alias template be a forwarding reference?

It seems that the following code works in both Clang 3.7.0 (demo) and GCC 6.0.0 (demo):

template <class T>
using forwarding_reference = T&&;

template <class T>
void foo(forwarding_reference<T>) {}

int main()
{
  int i{};
  foo(i);
  foo(1);
}

Are the compilers right to substitute the alias template for a forwarding reference and this could be a fancy way of writing one?


Aucun commentaire:

Enregistrer un commentaire