constexpr function1 [C++] 함수 : constexpr function constexpr function https://en.cppreference.com/w/cpp/keyword/constexpr constexpr 상수 constexpr int c = 1; constexpr function : 함수 앞에 constexpr 이 있는 형태 - 컴파일 할 때 값을 결정할 수 있으면, 컴파일 할 때 함수를 바로 실행한다. - 함수 인자값을 컴파일 시간에 결정할 수 없으면, 실행시간에 함수를 실행한다. constexpr int add(int a, int b) { return a + b; } int main() { int x = 1; int y = 1; int n1 = add(1, 1); // 컴파일 할 때 값을 결정할 수 있으면, 컴파일 할 때 함수를 바로 실행함. int n2 =.. 2021. 8. 10. 이전 1 다음