大学课程乱写Day2

程序设计A
周三12到2点交流
浮点数和定点数

constexpr

#include <bits/stdc++.h>
using namespace std;
constexpr int f(int x){
	return x==1?1:f(x-1)+1;
}
constexpr int N=f(100);
int main(){
} 

decltype 自动推断表达式类型

#include <bits/stdc++.h>
using namespace std;
constexpr int f(int x){
	return x==1?1:f(x-1)+1;
}
constexpr int N=f(100);
template<class T1,class T2>
auto f(T1 x,T2 y)->decltype(x+y){
	return x+y;
}
int main(){
}
posted @ 2020-09-15 22:03  Yuhuger  阅读(98)  评论(0编辑  收藏  举报