C++: Add a test for constexpr functions

This commit is contained in:
Ian Lynagh
2019-01-25 11:38:27 +00:00
parent a9f8a53dac
commit 5db38ef14b
3 changed files with 40 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
constexpr int fun_constexpr();
int fun_not_constexpr();
constexpr int overloaded_fun(int i) {
return 5;
}
int overloaded_fun(float f) {
return 6;
}
template <typename T>
constexpr int template_fun(T t) {
return overloaded_fun(t);
}
void caller(void) {
int i;
float f;
template_fun(i);
template_fun(f);
}