#include <iostream>
#include <typeinfo>
#include <type_traits>
using namespace std;
class OuterType{
public:
    struct InnerType {int i; };
    
    InnerType GetInner();
    InnerType it;
};
//返回类型后置语法,将decltype和auto结果起来完成返回值类型的推导,
auto OuterType::GetInner() -> InnerType{
    return it;
}

//返回类型后置语法,将decltype和auto结果起来完成返回值类型的推导,
template <typename T, typename U>
auto add(T t, U u) -> decltype(t + u) {
    return t + u;
}
int main()
{
   return 0;
}

  

相关文章:

  • 2023-01-10
  • 2021-09-25
  • 2022-03-03
  • 2022-12-23
  • 2022-12-23
  • 2022-03-08
  • 2022-12-23
  • 2021-10-13
猜你喜欢
  • 2021-08-27
  • 2021-10-10
  • 2022-01-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案