Created
February 27, 2019 06:27
-
-
Save Bloofer/96fd93cd93fed751021d3ba5517c4414 to your computer and use it in GitHub Desktop.
constexpr example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constexpr double power( double x, unsigned int y ) | |
{ | |
return y == 1 ? x : x * power( x, y - 1 ) ; | |
} | |
int main() | |
{ | |
// 정수 식 | |
constexpr double a = power( 2, 32 ) ; | |
// 정수 식이 아니다 | |
double x = 2 ; unsigned int y = 32 ; | |
double b = power( x, y ) ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment