&和和std :: add_lvalue_reference

时间:2018-02-13 19:32:21

标签: c++ templates stl

在阅读有关c ++模板的一些SO问题时,通常是我没写的代码,我遇到了这样的构造:

template<class T>
std::add_lvalue_reference_t<T> my_foo(T &t) { /*do some stuff and return*/ }

另一方面,我一直在使用这样的东西:

template<class T>
T &my_foo(T &t) { /*do some stuff and return*/ }

所以我有几个问题:

  1. 这些代码片段是否相同?
  2. 如果没有,它们之间有什么区别?
  3. 如果没有,哪个更喜欢?

0 个答案:

没有答案