{"id":2131,"date":"2025-03-24T08:48:13","date_gmt":"2025-03-23T23:48:13","guid":{"rendered":"https:\/\/dexall.co.jp\/articles\/?p=2131"},"modified":"2025-03-24T08:48:38","modified_gmt":"2025-03-23T23:48:38","slug":"c%e3%81%ae%e3%82%aa%e3%83%bc%e3%83%90%e3%83%bc%e3%83%ad%e3%83%bc%e3%83%89%e3%82%92%e5%ae%8c%e5%85%a8%e7%90%86%e8%a7%a3%ef%bc%81%e7%8f%be%e5%a0%b4%e3%81%a7%e4%bd%bf%e3%81%88%e3%82%8b%e5%ae%9f","status":"publish","type":"post","link":"https:\/\/dexall.co.jp\/articles\/?p=2131","title":{"rendered":"C++\u306e\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3092\u5b8c\u5168\u7406\u89e3\uff01\u73fe\u5834\u3067\u4f7f\u3048\u308b\u5b9f\u8df5\u7684\u306a7\u3064\u306e\u5b9f\u8df5\u30c6\u30af\u30cb\u30c3\u30af"},"content":{"rendered":"\n<div class=\"toc\"><br \/>\n<b>Warning<\/b>:  Undefined array key \"is_admin\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>116<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_category_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>121<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>128<\/b><br \/>\n    <div id=\"toc_container\" class=\"sgb-toc--bullets js-smooth-scroll\" data-dialog-title=\"\u76ee\u6b21\">\n      <p class=\"toc_title\">\u76ee\u6b21 <\/p>\n      <ul class=\"toc_list\">  <li class=\"first\">    <a href=\"#i-0\">C++\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306e\u57fa\u790e\u77e5\u8b58<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-1\">\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3068\u306f\u4f55\u304b\uff1f\u95a2\u6570\u306e\u591a\u91cd\u5b9a\u7fa9\u306e\u672c\u8cea<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-3\">\u306a\u305c\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u304c\u5fc5\u8981\u306a\u306e\u304b\uff1f\u5b9f\u969b\u306e\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-5\">\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306e\u653b\u7565\u30c6\u30af\u30cb\u30c3\u30af<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-6\">\u623b\u308a\u5024\u306e\u578b\u3060\u3051\u304c\u7570\u306a\u308b\u95a2\u6570\u3092\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3059\u308b\u65b9\u6cd5<\/a>      <\/li>      <li>        <a href=\"#i-7\">\u5f15\u6570\u306e\u578b\u3084\u6570\u304c\u7570\u306a\u308b\u95a2\u6570\u3092\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3059\u308b\u969b\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-8\">\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u6d3b\u7528\u3057\u305f\u67d4\u8edf\u306a\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u5b9f\u88c5<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-9\">\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3067\u3088\u304f\u3042\u308b\u30d0\u30b0\u3068\u89e3\u6c7a\u7b56<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-10\">\u3042\u3044\u307e\u3044\u306a\u547c\u3073\u51fa\u3057\u3092\u9632\u3050\u305f\u3081\u306e\u8a2d\u8a08\u30dd\u30a4\u30f3\u30c8<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-11\">\u610f\u56f3\u305b\u306c\u6697\u9ed9\u306e\u578b\u5909\u63db\u3092\u9632\u3050\u30c6\u30af\u30cb\u30c3\u30af<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-12\">\u5b9f\u52d9\u3067\u4f7f\u3048\u308b\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u30d1\u30bf\u30fc\u30f3<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-13\">\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306e\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3067\u5b9f\u73fe\u3059\u308b\u67d4\u8edf\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u751f\u6210<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-14\">\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3092\u4f7f\u7528\u3057\u305f\u76f4\u611f\u7684\u306a\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u8a2d\u8a08<\/a>      <\/li>    <\/ul>  <\/li>  <li class=\"last\">    <a href=\"#i-15\">\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3068\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-16\">\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306e\u95a2\u6570\u89e3\u6c7a\u306e\u4ed5\u7d44\u307f\u3068\u6700\u9069\u5316<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-17\">\u5b9f\u884c\u6642\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3078\u306e\u5f71\u97ff\u3068\u5bfe\u7b56<\/a>      <\/li>    <\/ul>  <\/li><\/ul>\n      <a href=\"#\" class=\"sgb-toc-button js-toc-button\" rel=\"nofollow\" data-open-dialog=\"true\"><i class=\"fa fa-list\"><\/i><span class=\"sgb-toc-button__text\">\u76ee\u6b21\u3078<\/span><\/a>\n    <\/div><\/div><h2 class=\"wp-block-heading\" id=\"i-0\">C++\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306e\u57fa\u790e\u77e5\u8b58<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-1\">\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3068\u306f\u4f55\u304b\uff1f\u95a2\u6570\u306e\u591a\u91cd\u5b9a\u7fa9\u306e\u672c\u8cea<\/h3>\n\n\n\n<p>\u95a2\u6570\u306e\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\uff08\u591a\u91cd\u5b9a\u7fa9\uff09\u306f\u3001C++\u306b\u304a\u3051\u308b\u91cd\u8981\u306a\u6a5f\u80fd\u306e\u4e00\u3064\u3067\u3001\u540c\u3058\u540d\u524d\u306e\u95a2\u6570\u306b\u7570\u306a\u308b\u5f15\u6570\u30ea\u30b9\u30c8\u3092\u6301\u305f\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u6a5f\u80fd\u3067\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u4f3c\u305f\u3088\u3046\u306a\u51e6\u7406\u3092\u884c\u3046\u95a2\u6570\u7fa4\u306b\u540c\u3058\u540d\u524d\u3092\u4ed8\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u3001\u30b3\u30fc\u30c9\u306e\u53ef\u8aad\u6027\u3068\u4fdd\u5b88\u6027\u3092\u9ad8\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u306b\u57fa\u672c\u7684\u306a\u4f8b\u3092\u793a\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Calculator {\npublic:\n    \/\/ \u6574\u6570\u306e\u52a0\u7b97\n    int add(int a, int b) {\n        return a + b;\n    }\n\n    \/\/ \u6d6e\u52d5\u5c0f\u6570\u70b9\u6570\u306e\u52a0\u7b97\n    double add(double a, double b) {\n        return a + b;\n    }\n\n    \/\/ 3\u3064\u306e\u6574\u6570\u306e\u52a0\u7b97\n    int add(int a, int b, int c) {\n        return a + b + c;\n    }\n};<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-2\">\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306e\u8b58\u5225\u65b9\u6cd5<\/h4>\n\n\n\n<p>C++\u30b3\u30f3\u30d1\u30a4\u30e9\u306f\u4ee5\u4e0b\u306e\u8981\u7d20\u3092\u4f7f\u3063\u3066\u95a2\u6570\u3092\u8b58\u5225\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u95a2\u6570\u540d<\/li>\n\n\n\n<li>\u5f15\u6570\u306e\u578b<\/li>\n\n\n\n<li>\u5f15\u6570\u306e\u6570<\/li>\n\n\n\n<li>const\u4fee\u98fe\u5b50\u306e\u6709\u7121<\/li>\n\n\n\n<li>\u53c2\u7167\u4fee\u98fe\u5b50\u306e\u6709\u7121<\/li>\n<\/ol>\n\n\n\n<p>\u6ce8\u610f\u70b9\u3068\u3057\u3066\u3001<strong>\u623b\u308a\u5024\u306e\u578b\u3060\u3051\u304c\u7570\u306a\u308b\u5834\u5408\u306f\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3067\u304d\u307e\u305b\u3093<\/strong>\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">int getValue();      \/\/ OK\ndouble getValue();   \/\/ \u30a8\u30e9\u30fc\uff1a\u623b\u308a\u5024\u306e\u578b\u3060\u3051\u304c\u7570\u306a\u308b\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306f\u4e0d\u53ef<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-3\">\u306a\u305c\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u304c\u5fc5\u8981\u306a\u306e\u304b\uff1f\u5b9f\u969b\u306e\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9<\/h3>\n\n\n\n<p>\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306b\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u91cd\u8981\u306a\u30e1\u30ea\u30c3\u30c8\u304c\u3042\u308a\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30b3\u30fc\u30c9\u306e\u76f4\u611f\u6027\u5411\u4e0a<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">   class String {\n   public:\n       \/\/ \u6587\u5b57\u5217\u3067\u521d\u671f\u5316\n       String(const char* str) { \/* \u5b9f\u88c5 *\/ }\n       \/\/ \u6587\u5b57\u6570\u3068\u521d\u671f\u6587\u5b57\u3067\u521d\u671f\u5316\n       String(size_t n, char c) { \/* \u5b9f\u88c5 *\/ }\n       \/\/ \u30b3\u30d4\u30fc\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\n       String(const String&amp; other) { \/* \u5b9f\u88c5 *\/ }\n   };\n\n   \/\/ \u4f7f\u7528\u4f8b\n   String s1(\"Hello\");           \/\/ \u6587\u5b57\u5217\u304b\u3089\u4f5c\u6210\n   String s2(5, 'a');           \/\/ 'aaaaa'\u3092\u4f5c\u6210\n   String s3(s1);               \/\/ s1\u306e\u30b3\u30d4\u30fc\u3092\u4f5c\u6210<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u578b\u306e\u5b89\u5168\u6027\u78ba\u4fdd<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">   class Array {\n   public:\n       \/\/ \u5883\u754c\u30c1\u30a7\u30c3\u30af\u4ed8\u304d\u306e\u914d\u5217\u30a2\u30af\u30bb\u30b9\n       int&amp; at(size_t index) {\n           if (index &gt;= size) throw std::out_of_range(\"Index out of bounds\");\n           return data[index];\n       }\n\n       \/\/ const\u7248\u306e\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\n       const int&amp; at(size_t index) const {\n           if (index &gt;= size) throw std::out_of_range(\"Index out of bounds\");\n           return data[index];\n       }\n   private:\n       int* data;\n       size_t size;\n   };<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30b3\u30fc\u30c9\u306e\u518d\u5229\u7528\u6027\u5411\u4e0a<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">   class DataProcessor {\n   public:\n       \/\/ \u5358\u4e00\u5024\u306e\u51e6\u7406\n       void process(int value) {\n           \/\/ \u5358\u4e00\u5024\u306e\u51e6\u7406\u30ed\u30b8\u30c3\u30af\n       }\n\n       \/\/ \u914d\u5217\u306e\u51e6\u7406\n       void process(int* values, size_t count) {\n           for (size_t i = 0; i &lt; count; ++i) {\n               process(values[i]);  \/\/ \u5358\u4e00\u5024\u51e6\u7406\u3092\u518d\u5229\u7528\n           }\n       }\n\n       \/\/ \u30d9\u30af\u30bf\u306e\u51e6\u7406\n       void process(const std::vector&lt;int&gt;&amp; values) {\n           for (const auto&amp; value : values) {\n               process(value);      \/\/ \u5358\u4e00\u5024\u51e6\u7406\u3092\u518d\u5229\u7528\n           }\n       }\n   };<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-4\">\u5b9f\u8df5\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u4f8b<\/h4>\n\n\n\n<p>\u4ee5\u4e0b\u306b\u3001\u5b9f\u52d9\u3067\u3088\u304f\u4f7f\u7528\u3055\u308c\u308b\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u30d1\u30bf\u30fc\u30f3\u3092\u793a\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30ed\u30b0\u51fa\u529b\u95a2\u6570<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Logger {\npublic:\n    \/\/ \u57fa\u672c\u7684\u306a\u30ed\u30b0\u51fa\u529b\n    void log(const std::string&amp; message) {\n        std::cout &lt;&lt; \"[INFO] \" &lt;&lt; message &lt;&lt; std::endl;\n    }\n\n    \/\/ \u30a8\u30e9\u30fc\u30ec\u30d9\u30eb\u3092\u6307\u5b9a\u3057\u305f\u30ed\u30b0\u51fa\u529b\n    void log(const std::string&amp; message, LogLevel level) {\n        std::cout &lt;&lt; \"[\" &lt;&lt; getLevelString(level) &lt;&lt; \"] \" \n                 &lt;&lt; message &lt;&lt; std::endl;\n    }\n\n    \/\/ \u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u4ed8\u304d\u30ed\u30b0\u51fa\u529b\n    void log(const char* format, ...) {\n        \/\/ \u53ef\u5909\u5f15\u6570\u51e6\u7406\u306e\u5b9f\u88c5\n    }\n};<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30b9\u30de\u30fc\u30c8\u30ea\u30bd\u30fc\u30b9\u7ba1\u7406<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class ResourceManager {\npublic:\n    \/\/ \u30ea\u30bd\u30fc\u30b9\u306e\u65b0\u898f\u4f5c\u6210\n    Resource* create() {\n        return new Resource();\n    }\n\n    \/\/ \u65e2\u5b58\u30ea\u30bd\u30fc\u30b9\u306e\u30b3\u30d4\u30fc\u3092\u4f5c\u6210\n    Resource* create(const Resource&amp; other) {\n        return new Resource(other);\n    }\n\n    \/\/ \u30d1\u30e9\u30e1\u30fc\u30bf\u4ed8\u304d\u3067\u30ea\u30bd\u30fc\u30b9\u3092\u4f5c\u6210\n    Resource* create(const ResourceParams&amp; params) {\n        return new Resource(params);\n    }\n};<\/pre>\n\n\n\n<p>\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3092\u9069\u5207\u306b\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001API\u306e\u4f7f\u3044\u3084\u3059\u3055\u304c\u5411\u4e0a\u3057\u3001\u30b3\u30fc\u30c9\u306e\u4fdd\u5b88\u6027\u3082\u9ad8\u307e\u308a\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u904e\u5ea6\u306a\u4f7f\u7528\u306f\u907f\u3051\u3001\u5404\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306e\u5f79\u5272\u304c\u660e\u78ba\u306b\u306a\u308b\u3088\u3046\u306b\u8a2d\u8a08\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-5\">\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306e\u653b\u7565\u30c6\u30af\u30cb\u30c3\u30af<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-6\">\u623b\u308a\u5024\u306e\u578b\u3060\u3051\u304c\u7570\u306a\u308b\u95a2\u6570\u3092\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3059\u308b\u65b9\u6cd5<\/h3>\n\n\n\n<p>\u623b\u308a\u5024\u306e\u578b\u3060\u3051\u304c\u7570\u306a\u308b\u95a2\u6570\u306f\u76f4\u63a5\u7684\u306a\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306f\u3067\u304d\u307e\u305b\u3093\u304c\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u4ee3\u66ff\u624b\u6cd5\u304c\u3042\u308a\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30bf\u30b0\u30c7\u30a3\u30b9\u30d1\u30c3\u30c1\u3092\u4f7f\u7528\u3059\u308b\u65b9\u6cd5<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class ResultType {\npublic:\n    struct AsInt {};    \/\/ \u30bf\u30b0\u578b\n    struct AsDouble {}; \/\/ \u30bf\u30b0\u578b\n\n    \/\/ \u30bf\u30b0\u3092\u4f7f\u7528\u3057\u305f\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\n    int getValue(AsInt) const { return static_cast&lt;int&gt;(value); }\n    double getValue(AsDouble) const { return value; }\n\nprivate:\n    double value;\n};\n\n\/\/ \u4f7f\u7528\u4f8b\nResultType result;\nint intValue = result.getValue(ResultType::AsInt{});\ndouble doubleValue = result.getValue(ResultType::AsDouble{});<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u6d3b\u7528\u3059\u308b\u65b9\u6cd5<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class NumericConverter {\npublic:\n    template&lt;typename T&gt;\n    T convert() const {\n        if constexpr (std::is_same_v&lt;T, int&gt;) {\n            return static_cast&lt;int&gt;(value);\n        } else if constexpr (std::is_same_v&lt;T, double&gt;) {\n            return value;\n        }\n        static_assert(false, \"Unsupported type\");\n    }\n\nprivate:\n    double value;\n};\n\n\/\/ \u4f7f\u7528\u4f8b\nNumericConverter converter;\nint intResult = converter.convert&lt;int&gt;();\ndouble doubleResult = converter.convert&lt;double&gt;();<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-7\">\u5f15\u6570\u306e\u578b\u3084\u6570\u304c\u7570\u306a\u308b\u95a2\u6570\u3092\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3059\u308b\u969b\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5f15\u6570\u306e\u9806\u5e8f\u306e\u4e00\u8cab\u6027\u3092\u4fdd\u3064<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class DataProcessor {\npublic:\n    \/\/ Good: \u4e00\u8cab\u3057\u305f\u5f15\u6570\u306e\u9806\u5e8f\n    void process(const std::string&amp; data, int count) { \/* ... *\/ }\n    void process(const std::string&amp; data, int count, bool validate) { \/* ... *\/ }\n\n    \/\/ Bad: \u4e00\u8cab\u6027\u306e\u306a\u3044\u5f15\u6570\u306e\u9806\u5e8f\n    void process(int count, const std::string&amp; data) { \/* ... *\/ }  \/\/ \u907f\u3051\u308b\u3079\u304d\n};<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30c7\u30d5\u30a9\u30eb\u30c8\u5f15\u6570\u3068\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306e\u4f7f\u3044\u5206\u3051<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Configuration {\npublic:\n    \/\/ Good: \u30c7\u30d5\u30a9\u30eb\u30c8\u5f15\u6570\u3092\u4f7f\u7528\n    void setUp(const std::string&amp; name, bool verbose = false) { \/* ... *\/ }\n\n    \/\/ Bad: \u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3067\u30c7\u30d5\u30a9\u30eb\u30c8\u5f15\u6570\u3092\u6a21\u5023\n    void setUp(const std::string&amp; name) { \/* ... *\/ }           \/\/ \u907f\u3051\u308b\u3079\u304d\n    void setUp(const std::string&amp; name, bool verbose) { \/* ... *\/ }\n};<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u5f15\u6570\u306e\u578b\u5909\u63db\u3092\u8003\u616e\u3057\u305f\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class StringHandler {\npublic:\n    \/\/ \u6587\u5b57\u5217\u30ea\u30c6\u30e9\u30eb\u7528\n    void handle(const char* str) {\n        std::cout &lt;&lt; \"Handling C-string: \" &lt;&lt; str &lt;&lt; std::endl;\n    }\n\n    \/\/ std::string\u7528\n    void handle(const std::string&amp; str) {\n        std::cout &lt;&lt; \"Handling std::string: \" &lt;&lt; str &lt;&lt; std::endl;\n    }\n\n    \/\/ string_view\u7528\uff08C++17\u4ee5\u964d\uff09\n    void handle(std::string_view str) {\n        std::cout &lt;&lt; \"Handling string_view: \" &lt;&lt; str &lt;&lt; std::endl;\n    }\n};<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-8\">\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u6d3b\u7528\u3057\u305f\u67d4\u8edf\u306a\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u5b9f\u88c5<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>SFINAE\uff08Substitution Failure Is Not An Error\uff09\u3092\u4f7f\u7528\u3057\u305f\u6761\u4ef6\u4ed8\u304d\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Container {\npublic:\n    \/\/ \u30a4\u30c6\u30ec\u30fc\u30bf\u3092\u6301\u3064\u578b\u7528\u306e\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\n    template&lt;typename T&gt;\n    auto process(const T&amp; container)\n        -&gt; decltype(std::begin(container), void()) {\n        for (const auto&amp; item : container) {\n            \/\/ \u30b3\u30f3\u30c6\u30ca\u306e\u8981\u7d20\u3092\u51e6\u7406\n        }\n    }\n\n    \/\/ \u5358\u4e00\u5024\u7528\u306e\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\n    template&lt;typename T&gt;\n    auto process(const T&amp; value)\n        -&gt; decltype(static_cast&lt;void&gt;(value + 0)) {\n        \/\/ \u5358\u4e00\u5024\u3092\u51e6\u7406\n    }\n};<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30b3\u30f3\u30bb\u30d7\u30c8\u3092\u4f7f\u7528\u3057\u305f\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\uff08C++20\uff09<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;concepts&gt;\n\nclass ModernProcessor {\npublic:\n    \/\/ \u6570\u5024\u578b\u7528\u306e\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\n    template&lt;std::integral T&gt;\n    void process(T value) {\n        std::cout &lt;&lt; \"Processing integral value: \" &lt;&lt; value &lt;&lt; std::endl;\n    }\n\n    \/\/ \u6d6e\u52d5\u5c0f\u6570\u70b9\u578b\u7528\u306e\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\n    template&lt;std::floating_point T&gt;\n    void process(T value) {\n        std::cout &lt;&lt; \"Processing floating-point value: \" &lt;&lt; value &lt;&lt; std::endl;\n    }\n\n    \/\/ \u6587\u5b57\u5217\u578b\u7528\u306e\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\n    template&lt;typename T&gt;\n    requires std::convertible_to&lt;T, std::string_view&gt;\n    void process(const T&amp; value) {\n        std::cout &lt;&lt; \"Processing string-like value: \" &lt;&lt; value &lt;&lt; std::endl;\n    }\n};<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u53ef\u5909\u5f15\u6570\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3068\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306e\u7d44\u307f\u5408\u308f\u305b<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class VariadicProcessor {\npublic:\n    \/\/ \u30d9\u30fc\u30b9\u30b1\u30fc\u30b9\n    void process() {\n        std::cout &lt;&lt; \"End of processing\" &lt;&lt; std::endl;\n    }\n\n    \/\/ \u5358\u4e00\u5f15\u6570\u306e\u51e6\u7406\n    template&lt;typename T&gt;\n    void process(T&amp;&amp; arg) {\n        handleSingle(std::forward&lt;T&gt;(arg));\n    }\n\n    \/\/ \u8907\u6570\u5f15\u6570\u306e\u51e6\u7406\n    template&lt;typename T, typename... Args&gt;\n    void process(T&amp;&amp; first, Args&amp;&amp;... rest) {\n        handleSingle(std::forward&lt;T&gt;(first));\n        process(std::forward&lt;Args&gt;(rest)...);\n    }\n\nprivate:\n    template&lt;typename T&gt;\n    void handleSingle(T&amp;&amp; value) {\n        std::cout &lt;&lt; \"Processing: \" &lt;&lt; value &lt;&lt; std::endl;\n    }\n};<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30c6\u30af\u30cb\u30c3\u30af\u3092\u9069\u5207\u306b\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u578b\u5b89\u5168\u3067\u67d4\u8edf\u306a\u5b9f\u88c5\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u904e\u5ea6\u306b\u8907\u96d1\u306a\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306f\u907f\u3051\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u9069\u5207\u306a\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u63d0\u4f9b\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-9\">\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3067\u3088\u304f\u3042\u308b\u30d0\u30b0\u3068\u89e3\u6c7a\u7b56<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-10\">\u3042\u3044\u307e\u3044\u306a\u547c\u3073\u51fa\u3057\u3092\u9632\u3050\u305f\u3081\u306e\u8a2d\u8a08\u30dd\u30a4\u30f3\u30c8<\/h3>\n\n\n\n<p>\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306b\u304a\u3051\u308b\u3042\u3044\u307e\u3044\u306a\u547c\u3073\u51fa\u3057\u306f\u3001\u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc\u3084\u4e88\u671f\u305b\u306c\u52d5\u4f5c\u306e\u539f\u56e0\u3068\u306a\u308a\u307e\u3059\u3002\u4ee5\u4e0b\u306b\u4e3b\u306a\u554f\u984c\u30d1\u30bf\u30fc\u30f3\u3068\u89e3\u6c7a\u7b56\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5f15\u6570\u306e\u578b\u5909\u63db\u306b\u3088\u308b\u66d6\u6627\u6027<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u554f\u984c\u306e\u3042\u308b\u30b3\u30fc\u30c9\nclass NumberProcessor {\npublic:\n    void process(int value) {\n        std::cout &lt;&lt; \"Processing int: \" &lt;&lt; value &lt;&lt; std::endl;\n    }\n\n    void process(double value) {\n        std::cout &lt;&lt; \"Processing double: \" &lt;&lt; value &lt;&lt; std::endl;\n    }\n};\n\n\/\/ \u554f\u984c\u304c\u767a\u751f\u3059\u308b\u30b1\u30fc\u30b9\nNumberProcessor processor;\nprocessor.process(10L);  \/\/ long\u578b\u3092\u6e21\u3059\u3068\u3069\u3061\u3089\u3092\u547c\u3076\u3079\u304d\u304b\u66d6\u6627\n\n\/\/ \u89e3\u6c7a\u7b56\uff1a\u660e\u793a\u7684\u306a\u578b\u5909\u63db\u3092\u5f37\u5236\u3059\u308b\nclass ImprovedNumberProcessor {\npublic:\n    explicit ImprovedNumberProcessor() = default;\n\n    void process(int value) {\n        std::cout &lt;&lt; \"Processing int: \" &lt;&lt; value &lt;&lt; std::endl;\n    }\n\n    void process(double value) {\n        std::cout &lt;&lt; \"Processing double: \" &lt;&lt; value &lt;&lt; std::endl;\n    }\n\n    \/\/ long\u578b\u7528\u306e\u660e\u793a\u7684\u306a\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3092\u8ffd\u52a0\n    void process(long value) {\n        process(static_cast&lt;int&gt;(value));  \/\/ \u660e\u793a\u7684\u306bint\u7248\u3092\u547c\u3073\u51fa\u3059\n    }\n};<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u7d99\u627f\u3068\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306e\u7d44\u307f\u5408\u308f\u305b\u306b\u3088\u308b\u554f\u984c<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u554f\u984c\u306e\u3042\u308b\u30b3\u30fc\u30c9\nclass Base {\npublic:\n    virtual void handle(int value) {\n        std::cout &lt;&lt; \"Base: handling int\" &lt;&lt; std::endl;\n    }\n};\n\nclass Derived : public Base {\npublic:\n    void handle(double value) {  \/\/ \u65b0\u3057\u3044\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\n        std::cout &lt;&lt; \"Derived: handling double\" &lt;&lt; std::endl;\n    }\n    \/\/ Base::handle(int)\u304c\u96a0\u853d\u3055\u308c\u308b\uff01\n};\n\n\/\/ \u89e3\u6c7a\u7b56\uff1ausing\u5ba3\u8a00\u3092\u4f7f\u7528\u3059\u308b\nclass FixedDerived : public Base {\npublic:\n    using Base::handle;  \/\/ Base class\u306ehandle\u95a2\u6570\u3092\u5c0e\u5165\n\n    void handle(double value) {\n        std::cout &lt;&lt; \"Derived: handling double\" &lt;&lt; std::endl;\n    }\n};<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-11\">\u610f\u56f3\u305b\u306c\u6697\u9ed9\u306e\u578b\u5909\u63db\u3092\u9632\u3050\u30c6\u30af\u30cb\u30c3\u30af<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>explicit\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u6d3b\u7528<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class String {\npublic:\n    \/\/ \u554f\u984c\u306e\u3042\u308b\u30b3\u30fc\u30c9\n    String(int size) {  \/\/ \u6697\u9ed9\u7684\u306a\u5909\u63db\u3092\u8a31\u53ef\n        buffer.resize(size);\n    }\n\n    \/\/ \u6539\u5584\u3055\u308c\u305f\u30b3\u30fc\u30c9\n    explicit String(int size) {  \/\/ \u6697\u9ed9\u7684\u306a\u5909\u63db\u3092\u7981\u6b62\n        buffer.resize(size);\n    }\n\nprivate:\n    std::vector&lt;char&gt; buffer;\n};\n\n\/\/ \u4f7f\u7528\u4f8b\nvoid processString(const String&amp; str) {\n    \/\/ \u51e6\u7406\n}\n\n\/\/ \u554f\u984c\u306e\u3042\u308b\u30b3\u30fc\u30c9\nprocessString(42);  \/\/ \u6697\u9ed9\u7684\u306a\u5909\u63db\u304c\u767a\u751f\n\n\/\/ \u6539\u5584\u3055\u308c\u305f\u30b3\u30fc\u30c9\nprocessString(String(42));  \/\/ \u660e\u793a\u7684\u306a\u5909\u63db\u304c\u5fc5\u8981<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u578b\u5b89\u5168\u306a\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u8a2d\u8a08<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class SafeCalculator {\npublic:\n    \/\/ \u578b\u5b89\u5168\u306a\u8a08\u7b97\u6a5f\u80fd\n    template&lt;typename T&gt;\n    T add(T a, T b) {\n        static_assert(std::is_arithmetic_v&lt;T&gt;, \n                     \"Arithmetic type required\");\n        return a + b;\n    }\n\n    \/\/ \u7570\u306a\u308b\u578b\u306e\u6f14\u7b97\u3092\u660e\u793a\u7684\u306b\u7981\u6b62\n    template&lt;typename T, typename U&gt;\n    auto add(T, U) = delete;\n\n    \/\/ \u5fc5\u8981\u306a\u5834\u5408\u306f\u660e\u793a\u7684\u306a\u5909\u63db\u95a2\u6570\u3092\u63d0\u4f9b\n    template&lt;typename T, typename U&gt;\n    auto addWithConversion(T a, U b) {\n        using CommonType = std::common_type_t&lt;T, U&gt;;\n        return static_cast&lt;CommonType&gt;(a) + \n               static_cast&lt;CommonType&gt;(b);\n    }\n};<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30c7\u30d0\u30c3\u30b0\u7528\u306e\u30a2\u30b5\u30fc\u30c8\u8ffd\u52a0<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class ResourceManager {\npublic:\n    void allocate(size_t size) {\n        assert(size &gt; 0 &amp;&amp; \"Size must be positive\");\n        \/\/ \u30ea\u30bd\u30fc\u30b9\u5272\u308a\u5f53\u3066\u51e6\u7406\n    }\n\n    void allocate(size_t size, int alignment) {\n        assert(size &gt; 0 &amp;&amp; \"Size must be positive\");\n        assert((alignment &amp; (alignment - 1)) == 0 &amp;&amp; \n               \"Alignment must be power of 2\");\n        \/\/ \u30a2\u30e9\u30a4\u30e1\u30f3\u30c8\u4ed8\u304d\u30ea\u30bd\u30fc\u30b9\u5272\u308a\u5f53\u3066\u51e6\u7406\n    }\n\n    template&lt;typename T&gt;\n    void allocate(size_t count) {\n        static_assert(std::is_trivially_constructible_v&lt;T&gt;,\n                     \"Type must be trivially constructible\");\n        allocate(count * sizeof(T));\n    }\n};<\/pre>\n\n\n\n<p>\u30c7\u30d0\u30c3\u30b0\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u30c1\u30a7\u30c3\u30af<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">template&lt;typename T&gt;\nclass TypeChecker {\n    static_assert(std::is_copy_constructible_v&lt;T&gt;,\n                 \"Type must be copy constructible\");\n    static_assert(!std::is_pointer_v&lt;T&gt;,\n                 \"Pointers are not allowed\");\npublic:\n    void process(const T&amp; value) {\n        \/\/ \u5b89\u5168\u306a\u51e6\u7406\n    }\n};<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>\u5b9f\u884c\u6642\u30c1\u30a7\u30c3\u30af<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class RuntimeChecker {\npublic:\n    template&lt;typename T&gt;\n    void validate(const T&amp; value) {\n        if constexpr (std::is_integral_v&lt;T&gt;) {\n            if (value &lt; 0) {\n                throw std::invalid_argument(\n                    \"Negative values are not allowed\");\n            }\n        }\n        \/\/ \u4ed6\u306e\u578b\u306b\u5bfe\u3059\u308b\u691c\u8a3c\n    }\n};<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30c6\u30af\u30cb\u30c3\u30af\u3092\u9069\u5207\u306b\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u5805\u7262\u306a\u30b3\u30fc\u30c9\u3092\u4f5c\u6210\u3067\u304d\u307e\u3059\u3002\u5e38\u306b\u30b3\u30fc\u30c9\u30ec\u30d3\u30e5\u30fc\u3068\u30c6\u30b9\u30c8\u3092\u901a\u3058\u3066\u3001\u610f\u56f3\u3057\u306a\u3044\u52d5\u4f5c\u304c\u767a\u751f\u3057\u3066\u3044\u306a\u3044\u304b\u78ba\u8a8d\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-12\">\u5b9f\u52d9\u3067\u4f7f\u3048\u308b\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u30d1\u30bf\u30fc\u30f3<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-13\">\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306e\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3067\u5b9f\u73fe\u3059\u308b\u67d4\u8edf\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u751f\u6210<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30d5\u30a1\u30af\u30c8\u30ea\u30fc\u30e1\u30bd\u30c3\u30c9\u30d1\u30bf\u30fc\u30f3\u3068\u306e\u7d44\u307f\u5408\u308f\u305b<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class NetworkConnection {\npublic:\n    \/\/ \u6a19\u6e96\u7684\u306aTCP\u63a5\u7d9a\u7528\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\n    NetworkConnection(const std::string&amp; host, uint16_t port)\n        : host_(host), port_(port), type_(ConnectionType::TCP) {\n        initializeTCP();\n    }\n\n    \/\/ UNIX domain\u30bd\u30b1\u30c3\u30c8\u7528\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\n    explicit NetworkConnection(const std::string&amp; socketPath)\n        : socketPath_(socketPath), type_(ConnectionType::UNIX) {\n        initializeUnixSocket();\n    }\n\n    \/\/ \u9759\u7684\u30d5\u30a1\u30af\u30c8\u30ea\u30fc\u30e1\u30bd\u30c3\u30c9\n    static NetworkConnection createSecure(\n        const std::string&amp; host, \n        uint16_t port,\n        const SSLConfig&amp; config) {\n        NetworkConnection conn(host, port);\n        conn.setupSSL(config);\n        return conn;\n    }\n\nprivate:\n    enum class ConnectionType { TCP, UNIX };\n    std::string host_;\n    std::string socketPath_;\n    uint16_t port_{0};\n    ConnectionType type_;\n\n    void initializeTCP() { \/* TCP\u521d\u671f\u5316\u51e6\u7406 *\/ }\n    void initializeUnixSocket() { \/* UNIX\u30bd\u30b1\u30c3\u30c8\u521d\u671f\u5316\u51e6\u7406 *\/ }\n    void setupSSL(const SSLConfig&amp; config) { \/* SSL\u8a2d\u5b9a\u51e6\u7406 *\/ }\n};\n\n\/\/ \u4f7f\u7528\u4f8b\nauto tcpConn = NetworkConnection(\"localhost\", 8080);\nauto unixConn = NetworkConnection(\"\/tmp\/app.sock\");\nauto secureConn = NetworkConnection::createSecure(\"example.com\", 443, sslConfig);<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30d3\u30eb\u30c0\u30fc\u30d1\u30bf\u30fc\u30f3\u3068\u306e\u7d71\u5408<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class DocumentBuilder;  \/\/ \u524d\u65b9\u5ba3\u8a00\n\nclass Document {\npublic:\n    \/\/ \u7a7a\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u4f5c\u6210\n    Document() = default;\n\n    \/\/ \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u304b\u3089\u306e\u4f5c\u6210\n    explicit Document(const std::string&amp; templateName)\n        : content_(loadTemplate(templateName)) {}\n\n    \/\/ \u30d3\u30eb\u30c0\u30fc\u304b\u3089\u306e\u4f5c\u6210\n    explicit Document(const DocumentBuilder&amp; builder);\n\n    \/\/ \u30b3\u30d4\u30fc\u7981\u6b62\n    Document(const Document&amp;) = delete;\n    Document&amp; operator=(const Document&amp;) = delete;\n\n    \/\/ \u30e0\u30fc\u30d6\u53ef\u80fd\n    Document(Document&amp;&amp;) noexcept = default;\n    Document&amp; operator=(Document&amp;&amp;) noexcept = default;\n\nprivate:\n    std::string content_;\n    std::vector&lt;std::string&gt; sections_;\n\n    static std::string loadTemplate(const std::string&amp; name);\n};\n\nclass DocumentBuilder {\npublic:\n    DocumentBuilder&amp; addTitle(const std::string&amp; title) {\n        title_ = title;\n        return *this;\n    }\n\n    DocumentBuilder&amp; addSection(const std::string&amp; section) {\n        sections_.push_back(section);\n        return *this;\n    }\n\n    Document build() const {\n        return Document(*this);\n    }\n\nprivate:\n    friend class Document;\n    std::string title_;\n    std::vector&lt;std::string&gt; sections_;\n};<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-14\">\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3092\u4f7f\u7528\u3057\u305f\u76f4\u611f\u7684\u306a\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u8a2d\u8a08<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u6570\u5b66\u7684\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Vector3D {\npublic:\n    Vector3D(double x = 0.0, double y = 0.0, double z = 0.0)\n        : x_(x), y_(y), z_(z) {}\n\n    \/\/ \u52a0\u7b97\u6f14\u7b97\u5b50\n    Vector3D operator+(const Vector3D&amp; other) const {\n        return Vector3D(x_ + other.x_, y_ + other.y_, z_ + other.z_);\n    }\n\n    \/\/ \u8907\u5408\u4ee3\u5165\u6f14\u7b97\u5b50\n    Vector3D&amp; operator+=(const Vector3D&amp; other) {\n        x_ += other.x_;\n        y_ += other.y_;\n        z_ += other.z_;\n        return *this;\n    }\n\n    \/\/ \u30b9\u30ab\u30e9\u30fc\u4e57\u7b97\n    Vector3D operator*(double scalar) const {\n        return Vector3D(x_ * scalar, y_ * scalar, z_ * scalar);\n    }\n\n    \/\/ \u30d5\u30ec\u30f3\u30c9\u95a2\u6570\u3068\u3057\u3066\u306e\u30b9\u30ab\u30e9\u30fc\u4e57\u7b97\uff08\u4ea4\u63db\u5247\u306e\u305f\u3081\uff09\n    friend Vector3D operator*(double scalar, const Vector3D&amp; vec) {\n        return vec * scalar;\n    }\n\n    \/\/ \u6bd4\u8f03\u6f14\u7b97\u5b50\n    bool operator==(const Vector3D&amp; other) const {\n        const double epsilon = 1e-10;\n        return std::abs(x_ - other.x_) &lt; epsilon &amp;&amp;\n               std::abs(y_ - other.y_) &lt; epsilon &amp;&amp;\n               std::abs(z_ - other.z_) &lt; epsilon;\n    }\n\n    \/\/ \u30b9\u30c8\u30ea\u30fc\u30e0\u51fa\u529b\u6f14\u7b97\u5b50\n    friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const Vector3D&amp; vec) {\n        return os &lt;&lt; \"(\" &lt;&lt; vec.x_ &lt;&lt; \", \" &lt;&lt; vec.y_ &lt;&lt; \", \" &lt;&lt; vec.z_ &lt;&lt; \")\";\n    }\n\nprivate:\n    double x_, y_, z_;\n};<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30b9\u30de\u30fc\u30c8\u30dd\u30a4\u30f3\u30bf\u98a8\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">template&lt;typename T&gt;\nclass ResourceHandle {\npublic:\n    \/\/ \u30c7\u30d5\u30a9\u30eb\u30c8\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\n    ResourceHandle() : ptr_(nullptr) {}\n\n    \/\/ \u30ea\u30bd\u30fc\u30b9\u6240\u6709\u6a29\u79fb\u8ee2\n    explicit ResourceHandle(T* ptr) : ptr_(ptr) {}\n\n    \/\/ \u30c7\u30b9\u30c8\u30e9\u30af\u30bf\u3067\u30ea\u30bd\u30fc\u30b9\u89e3\u653e\n    ~ResourceHandle() {\n        delete ptr_;\n    }\n\n    \/\/ \u30e0\u30fc\u30d6\u30bb\u30de\u30f3\u30c6\u30a3\u30af\u30b9\n    ResourceHandle(ResourceHandle&amp;&amp; other) noexcept\n        : ptr_(other.ptr_) {\n        other.ptr_ = nullptr;\n    }\n\n    ResourceHandle&amp; operator=(ResourceHandle&amp;&amp; other) noexcept {\n        if (this != &amp;other) {\n            delete ptr_;\n            ptr_ = other.ptr_;\n            other.ptr_ = nullptr;\n        }\n        return *this;\n    }\n\n    \/\/ \u30b3\u30d4\u30fc\u7981\u6b62\n    ResourceHandle(const ResourceHandle&amp;) = delete;\n    ResourceHandle&amp; operator=(const ResourceHandle&amp;) = delete;\n\n    \/\/ \u30dd\u30a4\u30f3\u30bf\u6f14\u7b97\u5b50\u306e\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\n    T* operator-&gt;() const {\n        if (!ptr_) throw std::runtime_error(\"Null pointer access\");\n        return ptr_;\n    }\n\n    T&amp; operator*() const {\n        if (!ptr_) throw std::runtime_error(\"Null pointer access\");\n        return *ptr_;\n    }\n\n    \/\/ bool\u5909\u63db\u6f14\u7b97\u5b50\n    explicit operator bool() const {\n        return ptr_ != nullptr;\n    }\n\nprivate:\n    T* ptr_;\n};<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30d3\u30b8\u30cd\u30b9\u30ed\u30b8\u30c3\u30af\u5411\u3051\u306e\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Money {\npublic:\n    explicit Money(decimal amount, const std::string&amp; currency)\n        : amount_(amount), currency_(currency) {}\n\n    Money operator+(const Money&amp; other) const {\n        if (currency_ != other.currency_) {\n            throw std::invalid_argument(\"Currency mismatch\");\n        }\n        return Money(amount_ + other.amount_, currency_);\n    }\n\n    Money operator*(double multiplier) const {\n        return Money(amount_ * multiplier, currency_);\n    }\n\n    bool operator&lt;(const Money&amp; other) const {\n        if (currency_ != other.currency_) {\n            throw std::invalid_argument(\"Currency mismatch\");\n        }\n        return amount_ &lt; other.amount_;\n    }\n\n    \/\/ \u901a\u8ca8\u63db\u7b97\u30b5\u30dd\u30fc\u30c8\n    Money convertTo(const std::string&amp; targetCurrency, \n                   const ExchangeRate&amp; rate) const {\n        if (currency_ == targetCurrency) return *this;\n        return Money(amount_ * rate.getRate(currency_, targetCurrency),\n                    targetCurrency);\n    }\n\nprivate:\n    decimal amount_;\n    std::string currency_;\n};\n\n\/\/ \u4f7f\u7528\u4f8b\nMoney salary(5000, \"USD\");\nMoney bonus(1000, \"USD\");\nMoney totalCompensation = salary + bonus;\nMoney yearlyBonus = bonus * 12;<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30d1\u30bf\u30fc\u30f3\u3092\u9069\u5207\u306b\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u4f7f\u3044\u3084\u3059\u304f\u4fdd\u5b88\u6027\u306e\u9ad8\u3044API\u3092\u8a2d\u8a08\u3067\u304d\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u6f14\u7b97\u5b50\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u306f\u76f4\u611f\u7684\u306a\u610f\u5473\u3092\u6301\u3064\u5834\u5408\u306b\u306e\u307f\u4f7f\u7528\u3057\u3001\u904e\u5ea6\u306a\u4f7f\u7528\u306f\u907f\u3051\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-15\">\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3068\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-16\">\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306e\u95a2\u6570\u89e3\u6c7a\u306e\u4ed5\u7d44\u307f\u3068\u6700\u9069\u5316<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u89e3\u6c7a\u306e\u30b3\u30b9\u30c8<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class StringProcessor {\npublic:\n    \/\/ \u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306b\u89e3\u6c7a\u3055\u308c\u308b\u52b9\u7387\u7684\u306a\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\n    void process(const char* str) {\n        \/\/ C\u6587\u5b57\u5217\u306e\u76f4\u63a5\u51e6\u7406\n    }\n\n    void process(const std::string&amp; str) {\n        \/\/ \u6587\u5b57\u5217\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u51e6\u7406\n    }\n\n    \/\/ \u975e\u52b9\u7387\u7684\u306a\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\uff08\u907f\u3051\u308b\u3079\u304d\uff09\n    void process(std::string str) {  \/\/ \u5024\u6e21\u3057\n        \/\/ \u30b3\u30d4\u30fc\u304c\u767a\u751f\u3059\u308b\n    }\n};<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3068\u9759\u7684\u30c7\u30a3\u30b9\u30d1\u30c3\u30c1\u306e\u6700\u9069\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">template&lt;typename T&gt;\nclass OptimizedProcessor {\npublic:\n    \/\/ \u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306b\u6700\u9069\u5316\u3055\u308c\u308b\u51e6\u7406\n    template&lt;typename U = T&gt;\n    std::enable_if_t&lt;std::is_integral_v&lt;U&gt;&gt; process(U value) {\n        processIntegral(value);\n    }\n\n    template&lt;typename U = T&gt;\n    std::enable_if_t&lt;std::is_floating_point_v&lt;U&gt;&gt; process(U value) {\n        processFloat(value);\n    }\n\nprivate:\n    void processIntegral(T value) {\n        \/\/ \u6574\u6570\u578b\u5c02\u7528\u306e\u6700\u9069\u5316\u3055\u308c\u305f\u51e6\u7406\n    }\n\n    void processFloat(T value) {\n        \/\/ \u6d6e\u52d5\u5c0f\u6570\u70b9\u578b\u5c02\u7528\u306e\u6700\u9069\u5316\u3055\u308c\u305f\u51e6\u7406\n    }\n};\n\n\/\/ C++20\u3067\u306e\u6539\u5584\u7248\ntemplate&lt;typename T&gt;\nclass ModernProcessor {\npublic:\n    void process(std::integral auto value) {\n        processIntegral(value);\n    }\n\n    void process(std::floating_point auto value) {\n        processFloat(value);\n    }\n\nprivate:\n    \/\/ \u5b9f\u88c5\u306f\u540c\u3058\n};<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30a4\u30f3\u30e9\u30a4\u30f3\u5316\u306e\u6700\u9069\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class InlinedProcessor {\npublic:\n    \/\/ \u5c0f\u3055\u306a\u95a2\u6570\u306f\u81ea\u52d5\u7684\u306b\u30a4\u30f3\u30e9\u30a4\u30f3\u5316\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\n    inline void processSmall(int value) {\n        result_ += value * 2;\n    }\n\n    \/\/ \u5927\u304d\u306a\u95a2\u6570\u306f\u901a\u5e38\u30a4\u30f3\u30e9\u30a4\u30f3\u5316\u3055\u308c\u306a\u3044\n    void processLarge(const std::vector&lt;int&gt;&amp; values) {\n        for (const auto&amp; value : values) {\n            \/\/ \u8907\u96d1\u306a\u51e6\u7406\n        }\n    }\n\nprivate:\n    int result_{0};\n};<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-17\">\u5b9f\u884c\u6642\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3078\u306e\u5f71\u97ff\u3068\u5bfe\u7b56<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30e1\u30e2\u30ea\u52b9\u7387\u3092\u8003\u616e\u3057\u305f\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class MemoryEfficientString {\npublic:\n    \/\/ \u5c0f\u3055\u306a\u6587\u5b57\u5217\u7528\u306e\u6700\u9069\u5316\n    explicit MemoryEfficientString(const char* str) {\n        const size_t len = strlen(str);\n        if (len &lt;= SmallStringSize) {\n            \/\/ \u30b9\u30bf\u30c3\u30af\u4e0a\u306b\u76f4\u63a5\u4fdd\u5b58\n            std::copy(str, str + len + 1, small_buffer_);\n            is_small_ = true;\n        } else {\n            \/\/ \u30d2\u30fc\u30d7\u5272\u308a\u5f53\u3066\n            data_ = new char[len + 1];\n            std::copy(str, str + len + 1, data_);\n            is_small_ = false;\n        }\n    }\n\n    \/\/ \u30e0\u30fc\u30d6\u30bb\u30de\u30f3\u30c6\u30a3\u30af\u30b9\u5bfe\u5fdc\n    MemoryEfficientString(MemoryEfficientString&amp;&amp; other) noexcept {\n        if (other.is_small_) {\n            std::copy(other.small_buffer_,\n                     other.small_buffer_ + SmallStringSize,\n                     small_buffer_);\n        } else {\n            data_ = other.data_;\n            other.data_ = nullptr;\n        }\n        is_small_ = other.is_small_;\n    }\n\n    ~MemoryEfficientString() {\n        if (!is_small_) {\n            delete[] data_;\n        }\n    }\n\nprivate:\n    static constexpr size_t SmallStringSize = 16;\n    union {\n        char* data_;\n        char small_buffer_[SmallStringSize];\n    };\n    bool is_small_;\n};<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30e1\u30c8\u30ea\u30af\u30b9\u306e\u6e2c\u5b9a<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class PerformanceMetrics {\npublic:\n    template&lt;typename Func, typename... Args&gt;\n    static auto measureExecutionTime(Func&amp;&amp; func, Args&amp;&amp;... args) {\n        auto start = std::chrono::high_resolution_clock::now();\n\n        \/\/ \u95a2\u6570\u5b9f\u884c\n        std::forward&lt;Func&gt;(func)(std::forward&lt;Args&gt;(args)...);\n\n        auto end = std::chrono::high_resolution_clock::now();\n        return std::chrono::duration_cast&lt;std::chrono::microseconds&gt;\n               (end - start).count();\n    }\n};\n\n\/\/ \u4f7f\u7528\u4f8b\nvoid benchmarkOverloads() {\n    StringProcessor processor;\n    const char* cstr = \"Hello\";\n    std::string str = \"Hello\";\n\n    auto cstr_time = PerformanceMetrics::measureExecutionTime(\n        [&amp;]() { processor.process(cstr); }\n    );\n\n    auto str_time = PerformanceMetrics::measureExecutionTime(\n        [&amp;]() { processor.process(str); }\n    );\n\n    std::cout &lt;&lt; \"C-string processing time: \" &lt;&lt; cstr_time &lt;&lt; \"\u00b5s\\n\";\n    std::cout &lt;&lt; \"String processing time: \" &lt;&lt; str_time &lt;&lt; \"\u00b5s\\n\";\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u6700\u9069\u5316\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5f15\u6570\u306e\u53d7\u3051\u6e21\u3057<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class OptimizedClass {\npublic:\n    \/\/ \u5c0f\u3055\u306a\u578b\u306f\u5024\u6e21\u3057\n    void process(int value) {\n        \/\/ \u76f4\u63a5\u51e6\u7406\n    }\n\n    \/\/ \u5927\u304d\u306a\u578b\u306f const \u53c2\u7167\n    void process(const BigObject&amp; obj) {\n        \/\/ \u53c2\u7167\u7d4c\u7531\u3067\u51e6\u7406\n    }\n\n    \/\/ \u30e0\u30fc\u30d6\u53ef\u80fd\u306a\u578b\u306f\u30e6\u30cb\u30d0\u30fc\u30b5\u30eb\u53c2\u7167\n    template&lt;typename T&gt;\n    void process(T&amp;&amp; obj) {\n        \/\/ \u5b8c\u5168\u8ee2\u9001\n        processImpl(std::forward&lt;T&gt;(obj));\n    }\n\nprivate:\n    template&lt;typename T&gt;\n    void processImpl(T&amp;&amp; obj) {\n        \/\/ \u5b9f\u969b\u306e\u51e6\u7406\n    }\n};<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u623b\u308a\u5024\u306e\u6700\u9069\u5316\uff08RVO\/NRVO\uff09<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class ReturnValueOptimized {\npublic:\n    \/\/ RVO\u304c\u9069\u7528\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\n    std::vector&lt;int&gt; createVector(size_t size) {\n        std::vector&lt;int&gt; result;\n        result.reserve(size);\n        for (size_t i = 0; i &lt; size; ++i) {\n            result.push_back(i);\n        }\n        return result;  \/\/ \u30e0\u30fc\u30d6\u3082\u30b3\u30d4\u30fc\u3082\u767a\u751f\u3057\u306a\u3044\n    }\n\n    \/\/ NRVO\u304c\u9069\u7528\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\n    std::vector&lt;int&gt; createVectorNamed(size_t size) {\n        std::vector&lt;int&gt; result;\n        result.reserve(size);\n        for (size_t i = 0; i &lt; size; ++i) {\n            result.push_back(i);\n        }\n        return result;  \/\/ \u540d\u524d\u4ed8\u304d\u623b\u308a\u5024\u306e\u6700\u9069\u5316\n    }\n};<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af\u3092\u9069\u5207\u306b\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3092\u4f7f\u7528\u3057\u3064\u3064\u3082\u9ad8\u3044\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u7dad\u6301\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u904e\u5ea6\u306a\u6700\u9069\u5316\u306f\u53ef\u8aad\u6027\u3092\u640d\u306a\u3046\u53ef\u80fd\u6027\u304c\u3042\u308b\u305f\u3081\u3001\u30d7\u30ed\u30d5\u30a1\u30a4\u30ea\u30f3\u30b0\u3092\u884c\u3044\u3001\u672c\u5f53\u306b\u5fc5\u8981\u306a\u7b87\u6240\u306e\u307f\u6700\u9069\u5316\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Warning: Undefined array key &#8220;is_admin&#8221; in \/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/ &#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":{"0":"post-2131","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-cpp","7":"nothumb"},"_links":{"self":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2131"}],"version-history":[{"count":1,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2131\/revisions"}],"predecessor-version":[{"id":2132,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2131\/revisions\/2132"}],"wp:attachment":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}