Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is forward<T> the same as forward<T&&>?

Looking at the documentation for std::forward,

template< class T >
constexpr T&& forward( typename std::remove_reference<T>::type& t ) noexcept;
template< class T >
constexpr T&& forward( typename std::remove_reference<T>::type&& t ) noexcept;

Both functions return T&&, which (correct me if I'm wrong) collapses to

  • T& if T is an lvalue reference
  • T&& if T is an rvalue reference, or if T is not a reference

For an arbitrary type T which may be a reference, does reference collapsing always cause forward<T> to do the same as forward<T&&>?

If so, is there any reason to use forward<T&&>?

like image 919
Taylor Nichols Avatar asked Aug 02 '18 21:08

Taylor Nichols


People also ask

How are forward rates quoted?

Forward points are often quoted in numbers, such as +13.2 or minus -270.68. These represent 1/10,000, so +13.2 means 0.00132 when added to a currency spot price.

What is forward rate example?

Forward rate. A projection of future interest rates calculated from either spot rates or the yield curve. For example, suppose the one-year government bond was yielding 2% and the two-year bond was yielding 4%. The one year forward rate represents the one-year interest rate one year from now.

How do you calculate forward value?

forward price = spot price − cost of carry. The future value of that asset's dividends (this could also be coupons from bonds, monthly rent from a house, fruit from a crop, etc.) is calculated using the risk-free force of interest.

What is forward FX?

A forward exchange contract (FEC) is a special type of over-the-counter (OTC) foreign currency (forex) transaction entered into in order to exchange currencies that are not often traded in forex markets. These may include minor currencies as well as blocked or otherwise inconvertible currencies.


Video Answer


1 Answers

Does reference collapsing always cause forward<T> to do the same as forward<T&&>?

Yes.

[I]s there any reason to use forward<T&&>?

No.

Note that this is assuming that the only forwards in view are the two overloads you showed in std::.

like image 68
T.C. Avatar answered Oct 16 '22 10:10

T.C.