๋ฐ์ํ
constexpr
[C++11] keyword: constexpr
[C++11] keyword: constexpr
2020.07.231. ์ค๋ช
constexpr ํค์๋๋ ๊ฐ์ฒด๋ ํจ์ ์์ ๋ถ์ผ ์ ์๋ ํค์๋๋ก, ํด๋น ๊ฐ์ฒด๋ ํจ์์ ๋ฆฌํด ๊ฐ์ ์ปดํ์ผ ํ์์ ๊ฐ์ ์ ์ ์๋ค๋ ์๋ฏธ๋ฅผ ์ ๋ฌํ๋ค. int arr[size]; ์ ๋ฐฐ์ด ์ ์ธ์์ด ์ปดํ์ผ๋๊ธฐ ์ํด์๋ size๊ฐ ์ ์ ์์ ์์ด์ฌ์ผ ํ๊ณ template struct A { int operator()() { return N; } }; A a; ํ
ํ๋ฆฟ ํ์
์ธ์์ ๊ฒฝ์ฐ๋ ๋ง์ฐฌ๊ฐ์ง๋ก number๊ฐ ์ ์ ์์์์ด์ฌ๋ง ํ๋ค. ๊ทธ ์ธ์๋, enum A { a = number, b, c }; enum์์ ๊ฐ์ ์ง์ ํด์ค ๋์ ์ค๋ number ์ญ์ ์ ์ ์์ ์์ด์ฌ๋ง ํ๋ค. constexpr์ ์์ ๋งํ ๋๋ก, ์ด๋ ํ ์์ด ์์์์ด๋ผ๊ณ ๋ช
์ํด์ฃผ๋ ํค์๋๋ค. #include using names..