Folding reference

x& &=x&

x& && = x&

x&& & = x&

x&& && = x&&


example:

  template<typename _Tp>
  constexpr typename std::remove_reference<_Tp>::type&&
  move(_Tp&& __t) noexcept
  { return static_cast<typename std::remove_reference<_Tp>::type&&>(__t); }
Incoming is the right value, assuming T &&

1.move (T && && __t) -> move (T &&) instantiated as a template so that the right value of the parameter T &&

2.std::remove_reference<_Tp>::type&& ->T&&

3.方法为T&& move(T&&) { return static_cast<T&&>(__T);}


Incoming value is left, T &

1.move (T & && __ T) -> move (T &) it is instantiated as a template parameter T & Left

2.std::remove_reference<_Tp>::type&& ->T&&

3方法为T&& move(T&) { return static_cast<T&&>(__T);}


Reference c ++ primer Fifth Edition

Published 140 original articles · won praise 28 · views 180 000 +

Guess you like

Origin blog.csdn.net/qq_16097611/article/details/78944026