{"id":26751685,"url":"https://github.com/dplusic/moderncppdesign","last_synced_at":"2026-02-15T08:32:35.449Z","repository":{"id":127612355,"uuid":"114653013","full_name":"dplusic/ModernCppDesign","owner":"dplusic","description":"Study of \"Modern C++ Design\"","archived":false,"fork":false,"pushed_at":"2018-01-31T03:38:19.000Z","size":42,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-09T14:34:52.855Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dplusic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-18T14:52:26.000Z","updated_at":"2024-03-08T02:05:06.000Z","dependencies_parsed_at":"2023-07-09T08:32:34.543Z","dependency_job_id":null,"html_url":"https://github.com/dplusic/ModernCppDesign","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dplusic/ModernCppDesign","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dplusic%2FModernCppDesign","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dplusic%2FModernCppDesign/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dplusic%2FModernCppDesign/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dplusic%2FModernCppDesign/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dplusic","download_url":"https://codeload.github.com/dplusic/ModernCppDesign/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dplusic%2FModernCppDesign/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29473718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T06:58:05.414Z","status":"ssl_error","status_checked_at":"2026-02-15T06:58:05.085Z","response_time":118,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-28T12:27:00.952Z","updated_at":"2026-02-15T08:32:35.430Z","avatar_url":"https://github.com/dplusic.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# ModernCppDesign\nStudy of \"Modern C++ Design\"\n\n## Chapters\n\n#### Foreword by Scott Meyers\n##### Physical\u003c\u003e\n* Codes\n    * https://wandbox.org/permlink/c8ewOlhBqO0KnP40\n    * https://wandbox.org/permlink/a5nH0EInhRCp73qi (using `constexpr`)\n* Reference\n    * http://se.ethz.ch/~meyer/publications/OTHERS/scott_meyers/dimensions.pdf\n    * https://www.codeproject.com/Articles/447922/Application-of-Cplusplus-User-Defined-Literals-t\n    * https://benjaminjurke.com/content/articles/2015/compile-time-numerical-unit-dimension-checking/\n\n### Chapter 1 Policy-Based Class Design\n#### 1.4 The Benefit of Templates\n##### Several problems\n* Codes\n    * https://wandbox.org/permlink/kXbzl7humO4e4p8e\n* Reference\n    * http://lukaswoodtli.github.io/modern_cpp_design.html#the-benefit-of-templates\n    \n#### 1.6 Enriched Policies\n* :question: Is it possible to prevent missing to call `SetPrototype`?\n\n#### 1.7 Destructors of Policy Classes\n* :question: Is it possible to prevent unintended type casting?\n* :question: Is it neccessary to inherit Policy Classes?\n    \n#### Reference\n* https://www.slideshare.net/lactrious/policy-based-class-design\n\n\n### Chapter 2 Techniques\n\n#### 2.1 Compile-Time Assertions\n* :question: `error: invalid application of 'sizeof' to a function type`\n    * https://wandbox.org/permlink/NBgMWthHfZMqAm03\n    * reference: https://en.wikipedia.org/wiki/Most_vexing_parse#Example_with_classes\n    * https://wandbox.org/permlink/SSxKl3oZff6xAaAi (using curly brackets)\n* `reinterpret_cast` do check the case of losing precision.\n* Codes\n    * https://wandbox.org/permlink/gBoOuXovnIdkULnQ\n* Reference\n    * http://en.cppreference.com/w/cpp/language/static_assert\n    * http://en.cppreference.com/w/cpp/language/reinterpret_cast\n\n#### 2.4 Mapping Integral Constants to Types\n* Codes\n    * https://wandbox.org/permlink/v4sFH6NWrZEeEm8Y (using `constexpr` instead of `enum`)\n    * https://wandbox.org/permlink/mQG2JTPvXtBcLhsy (`cannot specialize a member of an unspecialized template`)\n\n#### 2.6 Type Selection\n* Reference\n    * http://en.cppreference.com/w/cpp/types/conditional\n\n#### 2.7 Detecting Convertibility and Inheritance at Compile Time\n* Reference\n    * http://en.cppreference.com/w/cpp/types/is_convertible\n    * http://en.cppreference.com/w/cpp/types/is_base_of\n    * http://en.cppreference.com/w/cpp/language/decltype\n\n#### 2.9. NullType and EmptyType\n* Reference\n    * http://en.cppreference.com/w/cpp/types/nullptr_t\n    * http://en.cppreference.com/w/cpp/types/void_t\n    \n#### 2.10 Type Traits\n* Reference\n    * https://sourceforge.net/p/loki-lib/code/HEAD/tree/trunk/include/loki/TypeTraits.h\n\n\n### Chapter 3 Typelists\n\n#### 3.1 The Need for Typelists\n* Reference\n    * Parameter pack: http://en.cppreference.com/w/cpp/language/parameter_pack\n\n#### 3.2 Defining Typelists\n* Codes\n    * https://wandbox.org/permlink/tAqQsDNAFKOmCesq (OK to omit a space between `\u003e\u003e`)\n* Reference\n    * http://www.boost.org/doc/libs/1_66_0/libs/mpl/doc/refmanual/list.html\n    * http://lacti.me/2014/06/29/variadic-template-typelist/\n\n#### 3.3 Linearizing Typelist Creation\n* Reference\n    * https://www.slideshare.net/lactrious/preprocessor-programming\n\n#### 3.4 Calculating Length\n* Codes\n    * exersise: https://wandbox.org/permlink/C7sB9Oeqsw3gWY0G\n\n#### 3.6 Indexed Access\n* Reference\n    * `TypeAtNonStrict`: https://sourceforge.net/p/loki-lib/code/HEAD/tree/trunk/include/loki/Typelist.h#l147\n\n#### 3.13 Class Generation with Typelists\n##### 3.13.1 Generating Scattered Hierarchies\n* Reference\n    * HierarchyGenerators.h: https://sourceforge.net/p/loki-lib/code/HEAD/tree/trunk/include/loki/HierarchyGenerators.h\n\n##### 3.13.2 Generating Tuples\n* Codes\n    * https://wandbox.org/permlink/DpLVNaiWCiLD8KXI (using variadic template)\n\n##### 3.13.3 Generating Linear Hierarchies\n* size of `GenLinearHierarchy` implmenting `GenScatterHierarchy`\n    * https://wandbox.org/permlink/DpLVNaiWCiLD8KXI\n\n#### 3.14 Summary\n```\nThe linear class hierarchy structure is the more size efficient one.\nA scattered class hierarchy has a useful property:\nAll instantiations of the user-defined template\n(passed as an argument to GenScatterHierarchy)\nare roots of the final class, as Figure 3.2 shows. \n```\n\n\n### Chapter 4 Small-Object Allocation\n\n#### 4.1 The Default Free Store Allocator\n* Reference\n    * http://en.cppreference.com/w/cpp/language/pimpl\n\n#### 4.2 The Workings of a Memory Allocator\n* Reference\n    * http://en.cppreference.com/w/cpp/language/bit_field\n\n#### 4.4 Chunks\n* The big problem\n    * :question: What means the undefined behaviour?\n        * What architectures can affect it?\n    * performance aspect: (http://www.cplusplus.com/forum/general/28371#msg152710)\n\n\n### Chapter 5 Generalized Functors\n\n#### 5.1 The Command Design Pattern\n* Reference\n    * http://en.cppreference.com/w/cpp/utility/functional/function\n\n#### 5.3 C++ Callable Entities\n* Reference\n    * https://www.go4expert.com/articles/cpp-closures-functors-lamdas-stdfunction-t34654/\n\n#### 5.4 The Functor Class Template Skeleton\n* Codes\n    * https://wandbox.org/permlink/WqFenYp4M90ascri (using variadic template)\n* Reference\n    * https://sourceforge.net/p/loki-lib/code/HEAD/tree/trunk/include/loki/Functor.h\n    * http://en.cppreference.com/w/cpp/memory/auto_ptr\n    * https://github.com/llvm-mirror/libcxx/blob/master/include/functional\n\n#### 5.6 Handling Functors\n* Codes\n    * https://wandbox.org/permlink/Z9q4rMUy87ZVrESj (if the type of a `Functor` and a functor do not match)\n    * https://wandbox.org/permlink/JUS8qHxa8fAOsR39 (instantiating member functions of a template class)\n\n#### 5.7 Build One, Get One Free\n* Codes\n    * https://wandbox.org/permlink/UKlTXBmcUHz5uwiz (type inference with function type)\n    * https://wandbox.org/permlink/xXsnDSVW3mEYmXX8 (no problem with overloaded functions)\n        * :question: Any issues?\n        * http://en.cppreference.com/w/cpp/language/template_argument_deduction\n\n#### 5.10 Binding \n* Reference\n    * http://en.cppreference.com/w/cpp/utility/functional/bind\n\n#### 5.8 Argument and Return Type Conversions\n* Reference\n    * CORBA: https://en.wikipedia.org/wiki/Common_Object_Request_Broker_Architecture\n    * hana: http://www.boost.org/doc/libs/1_66_0/libs/hana/doc/html/index.html\n\n#### 5.13 Real-World Issues II: Heap Allocation\n* Reference\n    * https://blogs.msdn.microsoft.com/oldnewthing/20040209-00/?p=40713\n    * http://lazarenko.me/wide-pointers/\n\n#### 5.14 Implementing Undo and Redo with Functor\n* Reference\n    * http://www.drdobbs.com/cpp/c-programming/184410722\n\n\n### Chapter 6. Implementing Singletons\n\n#### 6.6 Addressing the Dead Reference Problem (I): The Phoenix Singleton \n##### 6.6.1 Problems with atexit\n* Codes\n    * https://wandbox.org/permlink/lMzRm1UO3eoRowTY\n* Reference\n    * http://en.cppreference.com/w/cpp/utility/program/atexit\n\n#### 6.8 Implementing Singletons with Longevity \n* Reference\n    * http://en.cppreference.com/w/cpp/memory/c/realloc\n    * https://stackoverflow.com/questions/6784987/lokis-setlongevity-function-seems-unsafe-to-me-is-that-so\n\n\n## Reference\n* http://my.safaribooksonline.com/book/programming/cplusplus/0201704315\n* https://github.com/LukasWoodtli/ModernCppDesign\n* https://github.com/jwvg0425/ModernCppStudy\n* [PDF](https://goo.gl/anKnnF)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdplusic%2Fmoderncppdesign","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdplusic%2Fmoderncppdesign","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdplusic%2Fmoderncppdesign/lists"}