๊ธ€ ์ž‘์„ฑ์ž: ๋˜ฅํด๋ฒ .
๋ฐ˜์‘ํ˜•

1. ์„ค๋ช…


 statc_assert๋Š” C++11์— ์ถ”๊ฐ€๋œ ํ‚ค์›Œ๋“œ๋กœ, ์ธ์ž๋กœ ์ „๋‹ฌ๋œ ์‹์ด ์ฐธ์ธ์ง€ ์•„๋‹Œ์ง€ ์ปดํŒŒ์ผ ํƒ€์ž„์— ํ™•์ธํ•œ๋‹ค.

static_assert์— ์ „๋‹ฌ๋œ ์‹์ด ์ฐธ์ด๋ผ๋ฉด, ์ปดํŒŒ์ผ๋Ÿฌ์— ์˜ํ•ด ํ•ด๋‹น ์‹์€ ๋ฌด์‹œ๋˜๊ณ , ๊ฑฐ์ง“์ด๋ผ๋ฉด ํ•ด๋‹น ๋ฌธ์žฅ์—์„œ ์ปดํŒŒ์ผ ์˜ค๋ฅ˜๋ฅผ ๋ฐœ์ƒ์‹œํ‚จ๋‹ค.

 

static_assert( constant-expression, string-literal );
static_assert( constant-expression ); // C++17 (Visual Studio 2017 and later)

์ปดํŒŒ์ผ ํƒ€์ž„์— ์ˆ˜ํ–‰๋˜๋Š” ํ‚ค์›Œ๋“œ์ด๋ฏ€๋กœ ์ฒซ ๋ฒˆ์งธ ์ธ์ž ์—ญ์‹œ ์ปดํŒŒ์ผ ํƒ€์ž„์—ฌ ๊ฒฐ์ •๋  ์ˆ˜ ์žˆ๋Š” ์ธ์ž์—ฌ์•ผ ํ•œ๋‹ค.

 

static_assert(sizeof(void *) == 4, "64-bit code generation is not supported.");

 

 

 

2. ์ฐธ๊ณ  ๋ฐ ์ถœ์ฒ˜


https://docs.microsoft.com/ko-kr/cpp/cpp/static-assert?view=vs-2019
๋ฐ˜์‘ํ˜•

'Language > C++' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[C++] keyword: enum class  (0) 2020.07.23
[C++] keyword: static_cast, dynamic_cast, reinterpret_cast, const_cast  (0) 2020.07.23
[C++] keyword: noexcept  (0) 2020.07.23
[C++11] keyword: constexpr  (0) 2020.07.23
[C++] keyword: using  (0) 2020.07.23