次åã®C++ MIXã¯ã2025/02/21(é) 19:00-21:00ã«éå¬ãã¾ãã çºè¡¨ããåå ãå¾ ã¡ãã¦ããã¾ãã
Boost 1.87.0ããªãªã¼ã¹ããã¾ãã
Boost 1.87.0ããªãªã¼ã¹ããã¾ããã ãªãªã¼ã¹ãã¼ãã¯ãã¤ãã®ããã«æ¥æ¬èªè¨³ãããã®ãboostjpãµã¤ãã§å ¬éãã¦ãã¾ãã
C++ MIX #12 éå¬æ¡å
ã¬ãããã¯LABã«ã¦æ å ±çºä¿¡ã¨ãéã«ã¤ãã¦ã®è¨äºãæ¸ãã¾ãã
2023å¹´ãããç§ãé¢ãã£ã¦ããæ å ±çºä¿¡ã«ã¤ãã¦ã¹ãã³ãµã¼åéãéå§ãã¾ãããããã®ãããã®èãã«ã¤ãã¦è¨äºãæ¸ããã¦ããã ãã¾ããã
æç¶çãªæ å ±çºä¿¡ãæç¶çãªãªã¼ãã³ã½ã¼ã¹ã®éçºã®ããã®åãçµã¿ã¨ãã¦åèã«ãªãã°å¹¸ãã§ãã
ã¬ãããã¯LABã«ã¦æè¡æ¸ä»¥å¤ã®æ¬ãç´¹ä»ããè¨äºãæ¸ãã¾ãã
åç·¨ã§ã¯2024å¹´ç¾å¨ãããããããC++æ¸ç±ãç´¹ä»ãã¾ããã
å¾ç·¨ã§ã¯ãä»äºã§ã½ããã¦ã§ã¢éçºããªããããä½æã®æéã«C++æ¥æ¬èªãªãã¡ã¬ã³ã¹ãµã¤ããæ¸ç±ã®å·çãåå¼·ä¼ã®éå¬ãªã©ããã¦ããç«å ´ããããããããããæè¡æ¸ä»¥å¤ã®æ¬ãç´¹ä»ããè¨äºãæ¸ããã¦ããã ãã¾ããã
ã¬ãããã¯LABã«ã¦C++æ¬ã®ç´¹ä»è¨äºãæ¸ããã¦ããã ãã¾ãã
cpprefjp Tã·ã£ããä½ãã¾ãï¼
2024å¹´ãCEDECã§cpprefjpæå±ã®æ¹ã®çºè¡¨ãããã®ã§ãããã«åããã¦cpprefjp Tã·ã£ããä½ãã¾ãï¼
çºè¡¨è ã ãã§ãªããcpprefjpã®ã³ã³ããªãã¥ã¼ã¿ã¼ã¨ã¹ãã³ãµã¼ã®æ¹ããå®è²»ãããã ããã°çºæ³¨ãã¾ãã
ãã®æ©ä¼ã«ãcpprefjp Webãµã¤ãã®ç·¨éã«ææ¦ãã ããæ¹ãã¹ãã³ãµã¼ã«ãªã£ã¦ãã ããæ¹ããå¾ ã¡ãã¦ããã¾ãã
ã¹ãã³ãµã¼ã¯ãOpen Collectiveã§åéãã¦ãã¾ããã¹ãã³ãµã¼ã«ãªã£ã¦ããã ããæ¹ã¯ã1å¹´écpprefjp Webãµã¤ãã®ããããã¼ã¸ã«ããã´ç»åã¨ãªã³ã¯ãæ²è¼ããã¦ããã ãã¾ãã
Tã·ã£ãã®ãã¶ã¤ã³ã¯ä»¥ä¸ã«ãªãã¾ãã次ã®æ©ä¼ã¯ãããã©ããããããªãã®ã§ããã®æ©ä¼ã«ãã²ï¼
static_assertã®æ¯è¼å¤ãã¨ã©ã¼ã¡ãã»ã¼ã¸ã«è¡¨ç¤ºãã
C++ã®static_assert(A == B);
ã¯è¡¨æ失ææã«false
ã¨ãããã¨ããããããªãå ´åãããã¾ãã
GCC 12以ä¸ãClang 16以ä¸ã§ããã°ãæ¯è¼å¤ãã¨ã©ã¼ã¡ãã»ã¼ã¸ã«è¡¨ç¤ºãã¦ããã¾ãã
int main() { constexpr int a = 1; constexpr int b = 2; static_assert(a == b); }
GCC :
prog.cc: In function 'int main()': prog.cc:5:21: error: static assertion failed 5 | static_assert(a == b); | ~~^~~~ prog.cc:5:21: note: the comparison reduces to '(1 == 2)'
Clang :
prog.cc:5:5: error: static assertion failed due to requirement 'a == b' static_assert(a == b); ^ ~~~~~~ prog.cc:5:21: note: expression evaluates to '1 == 2' static_assert(a == b); ~~^~~~ 1 error generated.
ããããå¤ãã³ã³ãã¤ã©ã®å ´åã¯ãã¯ã©ã¹ã®éåãã³ãã¬ã¼ããã©ã¡ã¼ã¿ã¨ãã¦å·¦è¾ºãå³è¾ºã®å¤ãã¨ãããã®ãªãã§static_assert
ãããã¨ã§ãã¨ã©ã¼ã¡ãã»ã¼ã¸ã«ãã³ãã¬ã¼ããã©ã¡ã¼ã¿ãå«ãã¯ã©ã¹åã表示ãããã®ã§æ¯è¼å¤ããããããã«ã§ãã¾ãã
template <auto A, auto B> struct static_assert_eq { static constexpr bool value = true; static_assert(A == B); }; int main() { constexpr int a = 1; constexpr int b = 2; static_assert(static_assert_eq<a, b>::value); }
ã¡ã³ãå¤æ°å®£è¨ã®æèã§ä½¿ããããªå ´åã«ããã®ãããª2段éã®static_assert
ãå¿
è¦ã«ãªãã¾ãã
struct X { static constexpr int a = 1; static constexpr int b = 2; static_assert(static_assert_eq<a, b>::value); // æèçã«static_assert_eq<a, b>{};ã¯ã§ããªã };
C++ MIX #9 ã®æ¥ç¨æ¡å
3å¹´ã¶ãï¼C++åå¼·ä¼ãC++ MIXããéå¬ãã¾ãï¼
3å¹´ã¶ãã«C++åå¼·ä¼ãéå¬ãã¾ãï¼