From 51e30e77d1b28b4314cb58fb184238eac771857e Mon Sep 17 00:00:00 2001 From: Moritz Perschke Date: Wed, 12 Mar 2025 16:08:25 +0100 Subject: [PATCH 1/9] added godbolt links to chapter 01 --- 01_values/01_01_basic_values.cpp | 2 +- 01_values/01_02_basic_references.cpp | 2 +- 01_values/01_03_lifecycle_creation_destruction.cpp | 2 +- 01_values/01_04_lifecycle_copy_construction.cpp | 2 +- 01_values/01_05_lifecycle_raii.cpp | 1 + 01_values/01_06_advanced_string.cpp | 2 +- 01_values/01_07_advanced_string_move.cpp | 2 +- 7 files changed, 7 insertions(+), 6 deletions(-) diff --git a/01_values/01_01_basic_values.cpp b/01_values/01_01_basic_values.cpp index 9903b20..01520eb 100644 --- a/01_values/01_01_basic_values.cpp +++ b/01_values/01_01_basic_values.cpp @@ -1,4 +1,4 @@ - +// https://godbolt.org/z/cfqo6YK7K #include void f_int(int i) { diff --git a/01_values/01_02_basic_references.cpp b/01_values/01_02_basic_references.cpp index d596334..c3ed916 100644 --- a/01_values/01_02_basic_references.cpp +++ b/01_values/01_02_basic_references.cpp @@ -1,4 +1,4 @@ - +// https://godbolt.org/z/sGeWevjcv #include // we read "int&" as "integer reference" diff --git a/01_values/01_03_lifecycle_creation_destruction.cpp b/01_values/01_03_lifecycle_creation_destruction.cpp index 27a424b..66e3b20 100644 --- a/01_values/01_03_lifecycle_creation_destruction.cpp +++ b/01_values/01_03_lifecycle_creation_destruction.cpp @@ -1,4 +1,4 @@ - +// https://godbolt.org/z/eb5qK3KxE #include // a "struct" is just like a class, except for default visibility being "public" diff --git a/01_values/01_04_lifecycle_copy_construction.cpp b/01_values/01_04_lifecycle_copy_construction.cpp index 593727a..7a96618 100644 --- a/01_values/01_04_lifecycle_copy_construction.cpp +++ b/01_values/01_04_lifecycle_copy_construction.cpp @@ -1,4 +1,4 @@ - +// https://godbolt.org/z/o4MEPEjY1 #include struct C { diff --git a/01_values/01_05_lifecycle_raii.cpp b/01_values/01_05_lifecycle_raii.cpp index 670101e..ad9e52f 100644 --- a/01_values/01_05_lifecycle_raii.cpp +++ b/01_values/01_05_lifecycle_raii.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/zGsrxG91Y #include #include diff --git a/01_values/01_06_advanced_string.cpp b/01_values/01_06_advanced_string.cpp index b1f3b64..36ba299 100644 --- a/01_values/01_06_advanced_string.cpp +++ b/01_values/01_06_advanced_string.cpp @@ -1,4 +1,4 @@ - +// https://godbolt.org/z/9bYz4oP3z #include #include #include diff --git a/01_values/01_07_advanced_string_move.cpp b/01_values/01_07_advanced_string_move.cpp index fedfa39..acb6ab3 100644 --- a/01_values/01_07_advanced_string_move.cpp +++ b/01_values/01_07_advanced_string_move.cpp @@ -1,4 +1,4 @@ - +// https://godbolt.org/z/qKef3jdWq #include #include #include From 0ff70eb9651b26d9b402a53f9d7acc70dc7039fc Mon Sep 17 00:00:00 2001 From: Moritz Perschke Date: Wed, 12 Mar 2025 16:34:19 +0100 Subject: [PATCH 2/9] added godbolt links to chapter 02 Not all files got a godbolt link, as some aren't supposed to compile but only show bad/better design --- 02_classes_and_interfaces/02_01_basic_interfaces.cpp | 2 +- 02_classes_and_interfaces/02_04_return_smart_pointers.cpp | 1 + 02_classes_and_interfaces/02_07_virtual_inheritance.cpp | 1 + 02_classes_and_interfaces/02_08_private_inheritance.cpp | 1 + 02_classes_and_interfaces/02_09_operator_overloading.cpp | 1 + 02_classes_and_interfaces/02_10_friends.cpp | 1 + 02_classes_and_interfaces/02_11_hidden_friends.cpp | 1 + 7 files changed, 7 insertions(+), 1 deletion(-) diff --git a/02_classes_and_interfaces/02_01_basic_interfaces.cpp b/02_classes_and_interfaces/02_01_basic_interfaces.cpp index 6e6c5fc..bd6c6fd 100644 --- a/02_classes_and_interfaces/02_01_basic_interfaces.cpp +++ b/02_classes_and_interfaces/02_01_basic_interfaces.cpp @@ -1,4 +1,4 @@ - +// https://godbolt.org/z/TGqsGba5x // Some examples are taken (or minimally adapted) from the C++ Core Guidelines #include diff --git a/02_classes_and_interfaces/02_04_return_smart_pointers.cpp b/02_classes_and_interfaces/02_04_return_smart_pointers.cpp index 1e6c3c5..90edab2 100644 --- a/02_classes_and_interfaces/02_04_return_smart_pointers.cpp +++ b/02_classes_and_interfaces/02_04_return_smart_pointers.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/W7T7dKnoe #include #include diff --git a/02_classes_and_interfaces/02_07_virtual_inheritance.cpp b/02_classes_and_interfaces/02_07_virtual_inheritance.cpp index fd5ff64..c8be0ef 100644 --- a/02_classes_and_interfaces/02_07_virtual_inheritance.cpp +++ b/02_classes_and_interfaces/02_07_virtual_inheritance.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/c9EvnWffo #include class A { diff --git a/02_classes_and_interfaces/02_08_private_inheritance.cpp b/02_classes_and_interfaces/02_08_private_inheritance.cpp index 7cdb4d5..99837c9 100644 --- a/02_classes_and_interfaces/02_08_private_inheritance.cpp +++ b/02_classes_and_interfaces/02_08_private_inheritance.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/sWzYq9Mnj #include #include diff --git a/02_classes_and_interfaces/02_09_operator_overloading.cpp b/02_classes_and_interfaces/02_09_operator_overloading.cpp index 123eee4..43e2980 100644 --- a/02_classes_and_interfaces/02_09_operator_overloading.cpp +++ b/02_classes_and_interfaces/02_09_operator_overloading.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/ns1xecTfb #include #include diff --git a/02_classes_and_interfaces/02_10_friends.cpp b/02_classes_and_interfaces/02_10_friends.cpp index 150f388..7198f60 100644 --- a/02_classes_and_interfaces/02_10_friends.cpp +++ b/02_classes_and_interfaces/02_10_friends.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/KeThK93ox #include #include diff --git a/02_classes_and_interfaces/02_11_hidden_friends.cpp b/02_classes_and_interfaces/02_11_hidden_friends.cpp index d0d4539..7532496 100644 --- a/02_classes_and_interfaces/02_11_hidden_friends.cpp +++ b/02_classes_and_interfaces/02_11_hidden_friends.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/YEcffEEzo #include #include From 2972d891c0c1e015b789815f7cd8d5eb90d7b9ba Mon Sep 17 00:00:00 2001 From: Moritz Perschke Date: Wed, 12 Mar 2025 20:31:17 +0100 Subject: [PATCH 3/9] added godbolt links to chapter 03 --- 03_lambdas_and_algorithms/03_01_containers_sequence.cpp | 1 + 03_lambdas_and_algorithms/03_02_containers_associative.cpp | 1 + 03_lambdas_and_algorithms/03_03_containers_unordered.cpp | 1 + 03_lambdas_and_algorithms/03_04_iterators.cpp | 1 + 03_lambdas_and_algorithms/03_05_lambda_basics.cpp | 1 + 03_lambdas_and_algorithms/03_07_lambda_implementation.cpp | 1 + 03_lambdas_and_algorithms/03_08_alg_examples.cpp | 1 + 03_lambdas_and_algorithms/03_09_exec_policy_bench.cpp | 2 +- 8 files changed, 8 insertions(+), 1 deletion(-) diff --git a/03_lambdas_and_algorithms/03_01_containers_sequence.cpp b/03_lambdas_and_algorithms/03_01_containers_sequence.cpp index ddf8b41..b0e2fa7 100644 --- a/03_lambdas_and_algorithms/03_01_containers_sequence.cpp +++ b/03_lambdas_and_algorithms/03_01_containers_sequence.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/KhT8er4Wr #include #include #include diff --git a/03_lambdas_and_algorithms/03_02_containers_associative.cpp b/03_lambdas_and_algorithms/03_02_containers_associative.cpp index cc70d9a..63302e8 100644 --- a/03_lambdas_and_algorithms/03_02_containers_associative.cpp +++ b/03_lambdas_and_algorithms/03_02_containers_associative.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/q19so8Ya9 #include #include diff --git a/03_lambdas_and_algorithms/03_03_containers_unordered.cpp b/03_lambdas_and_algorithms/03_03_containers_unordered.cpp index a1c0edc..2a0458d 100644 --- a/03_lambdas_and_algorithms/03_03_containers_unordered.cpp +++ b/03_lambdas_and_algorithms/03_03_containers_unordered.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/bWY3jMqn8 #include #include diff --git a/03_lambdas_and_algorithms/03_04_iterators.cpp b/03_lambdas_and_algorithms/03_04_iterators.cpp index 4e9cbe1..ded8d09 100644 --- a/03_lambdas_and_algorithms/03_04_iterators.cpp +++ b/03_lambdas_and_algorithms/03_04_iterators.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/55rEh1avj #include #include #include diff --git a/03_lambdas_and_algorithms/03_05_lambda_basics.cpp b/03_lambdas_and_algorithms/03_05_lambda_basics.cpp index 98eebf6..4627161 100644 --- a/03_lambdas_and_algorithms/03_05_lambda_basics.cpp +++ b/03_lambdas_and_algorithms/03_05_lambda_basics.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/h8xMTYjj1 #include #include #include diff --git a/03_lambdas_and_algorithms/03_07_lambda_implementation.cpp b/03_lambdas_and_algorithms/03_07_lambda_implementation.cpp index 3fd73fa..90da76e 100644 --- a/03_lambdas_and_algorithms/03_07_lambda_implementation.cpp +++ b/03_lambdas_and_algorithms/03_07_lambda_implementation.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/W3T5oG5sc #include void test1() { diff --git a/03_lambdas_and_algorithms/03_08_alg_examples.cpp b/03_lambdas_and_algorithms/03_08_alg_examples.cpp index 5a0d4ff..00afef6 100644 --- a/03_lambdas_and_algorithms/03_08_alg_examples.cpp +++ b/03_lambdas_and_algorithms/03_08_alg_examples.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/ssKxxnb7q #include #include #include diff --git a/03_lambdas_and_algorithms/03_09_exec_policy_bench.cpp b/03_lambdas_and_algorithms/03_09_exec_policy_bench.cpp index 2448eb6..6e28732 100644 --- a/03_lambdas_and_algorithms/03_09_exec_policy_bench.cpp +++ b/03_lambdas_and_algorithms/03_09_exec_policy_bench.cpp @@ -1,5 +1,5 @@ // g++ main.cpp -O3 -std=c++20 -ltbb -Wall -Wextra -o main - +// https://godbolt.org/z/jso53sM1o #include #include #include From a5152180e03cdaf4ab3af343cf516baa2bfa1f7e Mon Sep 17 00:00:00 2001 From: Moritz Perschke Date: Wed, 12 Mar 2025 20:43:06 +0100 Subject: [PATCH 4/9] added godbolt links to chapter 04 --- 04_templates/04_01_function_templates_basic.cpp | 2 +- 04_templates/04_02_template_parameter_categories.cpp | 1 + 04_templates/04_03_template_parameter_packs.cpp | 1 + 04_templates/04_04_template_arguments.cpp | 1 + 04_templates/04_05_class_template_basics.cpp | 1 + 04_templates/04_06_template_specialization.cpp | 1 + 04_templates/04_07_class_template_arg_deduction.cpp | 2 +- 04_templates/04_08_variable_templates.cpp | 2 +- 04_templates/04_09_alias_templates.cpp | 2 ++ 04_templates/04_10_two_phase_lookup.cpp | 1 + 04_templates/04_11_parsing_hints.cpp | 1 + 11 files changed, 12 insertions(+), 3 deletions(-) diff --git a/04_templates/04_01_function_templates_basic.cpp b/04_templates/04_01_function_templates_basic.cpp index 34bfb4e..63a6b99 100644 --- a/04_templates/04_01_function_templates_basic.cpp +++ b/04_templates/04_01_function_templates_basic.cpp @@ -1,4 +1,4 @@ - +// https://godbolt.org/z/6M7sfK3jT #if true int abs(int x) { diff --git a/04_templates/04_02_template_parameter_categories.cpp b/04_templates/04_02_template_parameter_categories.cpp index a7f5f84..0e77456 100644 --- a/04_templates/04_02_template_parameter_categories.cpp +++ b/04_templates/04_02_template_parameter_categories.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/Wzx9GnzoT #include #include #include diff --git a/04_templates/04_03_template_parameter_packs.cpp b/04_templates/04_03_template_parameter_packs.cpp index 59a579e..2ffc713 100644 --- a/04_templates/04_03_template_parameter_packs.cpp +++ b/04_templates/04_03_template_parameter_packs.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/brz64acKa #include #include diff --git a/04_templates/04_04_template_arguments.cpp b/04_templates/04_04_template_arguments.cpp index 00fe4da..62c515e 100644 --- a/04_templates/04_04_template_arguments.cpp +++ b/04_templates/04_04_template_arguments.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/Gxn7Y7Tes #include #include #include diff --git a/04_templates/04_05_class_template_basics.cpp b/04_templates/04_05_class_template_basics.cpp index f582033..eb08ea1 100644 --- a/04_templates/04_05_class_template_basics.cpp +++ b/04_templates/04_05_class_template_basics.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/WE1YqvP7j #include #include diff --git a/04_templates/04_06_template_specialization.cpp b/04_templates/04_06_template_specialization.cpp index ab3f87c..7911605 100644 --- a/04_templates/04_06_template_specialization.cpp +++ b/04_templates/04_06_template_specialization.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/Yox7Y53We #include #include diff --git a/04_templates/04_07_class_template_arg_deduction.cpp b/04_templates/04_07_class_template_arg_deduction.cpp index f1f8a4d..00b5b89 100644 --- a/04_templates/04_07_class_template_arg_deduction.cpp +++ b/04_templates/04_07_class_template_arg_deduction.cpp @@ -1,5 +1,5 @@ // you can see this example working with recent GCC and Clang versions here: -// https://godbolt.org/z/WzFsJp +// https://godbolt.org/z/r6Ysq4dPe #include #include diff --git a/04_templates/04_08_variable_templates.cpp b/04_templates/04_08_variable_templates.cpp index c0d3da0..6feccbc 100644 --- a/04_templates/04_08_variable_templates.cpp +++ b/04_templates/04_08_variable_templates.cpp @@ -1,4 +1,4 @@ - +// https://godbolt.org/z/8PKz1bnYr // variable template for pi template diff --git a/04_templates/04_09_alias_templates.cpp b/04_templates/04_09_alias_templates.cpp index fd24655..9d57405 100644 --- a/04_templates/04_09_alias_templates.cpp +++ b/04_templates/04_09_alias_templates.cpp @@ -1,3 +1,5 @@ +// https://godbolt.org/z/PKTGr39Gh +#include #include template diff --git a/04_templates/04_10_two_phase_lookup.cpp b/04_templates/04_10_two_phase_lookup.cpp index c3364c2..666117b 100644 --- a/04_templates/04_10_two_phase_lookup.cpp +++ b/04_templates/04_10_two_phase_lookup.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/PM8edoq9f #include /// Non-dependent name diff --git a/04_templates/04_11_parsing_hints.cpp b/04_templates/04_11_parsing_hints.cpp index 18f963e..fa1bb80 100644 --- a/04_templates/04_11_parsing_hints.cpp +++ b/04_templates/04_11_parsing_hints.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/fM678oGcf #include /// Dependent name From 4c3a4092646cfc2a431008c2c7ed99048d767c53 Mon Sep 17 00:00:00 2001 From: Moritz Perschke Date: Thu, 13 Mar 2025 16:54:13 +0100 Subject: [PATCH 5/9] added godbolt links to chapter 05 --- 05_keyword_safari/05_01_storage_classes.cpp | 2 +- 05_keyword_safari/05_02_static_initialization.cpp | 1 + 05_keyword_safari/05_03_cv_qualification.cpp | 1 + 05_keyword_safari/05_04_static_members.cpp | 2 +- 05_keyword_safari/05_05_explicit_constructors.cpp | 1 + 05_keyword_safari/05_06_member_ref_qualifiers.cpp | 2 +- 05_keyword_safari/05_07_mutable_data_members.cpp | 2 +- 05_keyword_safari/05_08_constexpr.cpp | 3 +-- 05_keyword_safari/05_09_constevalinit.cpp | 2 +- 9 files changed, 9 insertions(+), 7 deletions(-) diff --git a/05_keyword_safari/05_01_storage_classes.cpp b/05_keyword_safari/05_01_storage_classes.cpp index 1dc6aeb..9ca0993 100644 --- a/05_keyword_safari/05_01_storage_classes.cpp +++ b/05_keyword_safari/05_01_storage_classes.cpp @@ -1,4 +1,4 @@ - +// https://godbolt.org/z/xPhrhdYs9 int global1; // global1: static storage duration, external linkage diff --git a/05_keyword_safari/05_02_static_initialization.cpp b/05_keyword_safari/05_02_static_initialization.cpp index b038980..25e2a47 100644 --- a/05_keyword_safari/05_02_static_initialization.cpp +++ b/05_keyword_safari/05_02_static_initialization.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/csjnTxjcT #include struct Trace { diff --git a/05_keyword_safari/05_03_cv_qualification.cpp b/05_keyword_safari/05_03_cv_qualification.cpp index 7b7b2fa..e275b56 100644 --- a/05_keyword_safari/05_03_cv_qualification.cpp +++ b/05_keyword_safari/05_03_cv_qualification.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/b3vzz9rdd void take_int_ref(int& i) {} diff --git a/05_keyword_safari/05_04_static_members.cpp b/05_keyword_safari/05_04_static_members.cpp index c128a9c..b0702ff 100644 --- a/05_keyword_safari/05_04_static_members.cpp +++ b/05_keyword_safari/05_04_static_members.cpp @@ -1,4 +1,4 @@ - +// https://godbolt.org/z/GvqvYEW1o #include struct Foo { diff --git a/05_keyword_safari/05_05_explicit_constructors.cpp b/05_keyword_safari/05_05_explicit_constructors.cpp index aab11bf..ff487e8 100644 --- a/05_keyword_safari/05_05_explicit_constructors.cpp +++ b/05_keyword_safari/05_05_explicit_constructors.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/hnhxejcfE #include struct Point { diff --git a/05_keyword_safari/05_06_member_ref_qualifiers.cpp b/05_keyword_safari/05_06_member_ref_qualifiers.cpp index 633e3ab..fa550a9 100644 --- a/05_keyword_safari/05_06_member_ref_qualifiers.cpp +++ b/05_keyword_safari/05_06_member_ref_qualifiers.cpp @@ -1,4 +1,4 @@ - +// https://godbolt.org/z/v757ca5oW class Vector { float contents[10]; diff --git a/05_keyword_safari/05_07_mutable_data_members.cpp b/05_keyword_safari/05_07_mutable_data_members.cpp index eb9f36e..793e0ad 100644 --- a/05_keyword_safari/05_07_mutable_data_members.cpp +++ b/05_keyword_safari/05_07_mutable_data_members.cpp @@ -1,4 +1,4 @@ - +// https://godbolt.org/z/43GhsYxnc class ComplexShape { mutable bool volumeCalculated = false; mutable double volume; diff --git a/05_keyword_safari/05_08_constexpr.cpp b/05_keyword_safari/05_08_constexpr.cpp index 5d95347..b098124 100644 --- a/05_keyword_safari/05_08_constexpr.cpp +++ b/05_keyword_safari/05_08_constexpr.cpp @@ -1,4 +1,4 @@ - +// https://godbolt.org/z/oTaPxP6Ec #include constexpr int fac(int n) { @@ -16,4 +16,3 @@ int main() { constN out1; } -// https://godbolt.org/g/XoaGL9 diff --git a/05_keyword_safari/05_09_constevalinit.cpp b/05_keyword_safari/05_09_constevalinit.cpp index 93796e2..4876ec2 100644 --- a/05_keyword_safari/05_09_constevalinit.cpp +++ b/05_keyword_safari/05_09_constevalinit.cpp @@ -1,5 +1,5 @@ // Sample adapted from cppreference -// Available in compiler explorer: https://godbolt.org/z/7YY3sb9YP +// Available in compiler explorer: https://godbolt.org/z/oKf63hzaE #include From ab5440fd2c3f352b24139d178a0dc0a2b88dcad4 Mon Sep 17 00:00:00 2001 From: Moritz Perschke Date: Thu, 13 Mar 2025 16:56:54 +0100 Subject: [PATCH 6/9] added godbolt links to chapter 06 --- 06_advanced_templates/06_01_simple_template_metafunction.cpp | 1 + 06_advanced_templates/06_02_type_parameter.cpp | 1 + 06_advanced_templates/06_03_type_result.cpp | 1 + 06_advanced_templates/06_04_refactoring_conventions.cpp | 1 + 06_advanced_templates/06_05_tuple_includes.cpp | 1 + 06_advanced_templates/06_06_tuple_includes_prime.cpp | 1 + 06_advanced_templates/06_07_dispatch.cpp | 1 + 06_advanced_templates/06_08_decltype_declval.cpp | 1 + 06_advanced_templates/06_09_sfinae.cpp | 1 + 06_advanced_templates/06_10_crtp.cpp | 1 + 10 files changed, 10 insertions(+) diff --git a/06_advanced_templates/06_01_simple_template_metafunction.cpp b/06_advanced_templates/06_01_simple_template_metafunction.cpp index 01b72e1..8a9e829 100644 --- a/06_advanced_templates/06_01_simple_template_metafunction.cpp +++ b/06_advanced_templates/06_01_simple_template_metafunction.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/oaWPrb6e5 #include #include diff --git a/06_advanced_templates/06_02_type_parameter.cpp b/06_advanced_templates/06_02_type_parameter.cpp index a4dd3b8..6edc767 100644 --- a/06_advanced_templates/06_02_type_parameter.cpp +++ b/06_advanced_templates/06_02_type_parameter.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/rj8avoKoz #include template diff --git a/06_advanced_templates/06_03_type_result.cpp b/06_advanced_templates/06_03_type_result.cpp index c9a7d77..3246f38 100644 --- a/06_advanced_templates/06_03_type_result.cpp +++ b/06_advanced_templates/06_03_type_result.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/K5Whq6Es4 #include #include diff --git a/06_advanced_templates/06_04_refactoring_conventions.cpp b/06_advanced_templates/06_04_refactoring_conventions.cpp index d740e43..6d198b1 100644 --- a/06_advanced_templates/06_04_refactoring_conventions.cpp +++ b/06_advanced_templates/06_04_refactoring_conventions.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/85b9Esxvn #include #include diff --git a/06_advanced_templates/06_05_tuple_includes.cpp b/06_advanced_templates/06_05_tuple_includes.cpp index 7a7089c..46826c2 100644 --- a/06_advanced_templates/06_05_tuple_includes.cpp +++ b/06_advanced_templates/06_05_tuple_includes.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/nhao6438h #include #include diff --git a/06_advanced_templates/06_06_tuple_includes_prime.cpp b/06_advanced_templates/06_06_tuple_includes_prime.cpp index c8cc306..1423565 100644 --- a/06_advanced_templates/06_06_tuple_includes_prime.cpp +++ b/06_advanced_templates/06_06_tuple_includes_prime.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/fnEPqs6jq #include #include diff --git a/06_advanced_templates/06_07_dispatch.cpp b/06_advanced_templates/06_07_dispatch.cpp index 5bfbf1b..57f3b8e 100644 --- a/06_advanced_templates/06_07_dispatch.cpp +++ b/06_advanced_templates/06_07_dispatch.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/Yx5G1zsME #include /// Scenario: ///////////////////////////////////////////////////////////////// diff --git a/06_advanced_templates/06_08_decltype_declval.cpp b/06_advanced_templates/06_08_decltype_declval.cpp index 8e959cb..3b27fb2 100644 --- a/06_advanced_templates/06_08_decltype_declval.cpp +++ b/06_advanced_templates/06_08_decltype_declval.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/5cY9v39Y9 #include #include diff --git a/06_advanced_templates/06_09_sfinae.cpp b/06_advanced_templates/06_09_sfinae.cpp index 6e04e4b..9c1f15e 100644 --- a/06_advanced_templates/06_09_sfinae.cpp +++ b/06_advanced_templates/06_09_sfinae.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/jr9cr9GPP #include #include diff --git a/06_advanced_templates/06_10_crtp.cpp b/06_advanced_templates/06_10_crtp.cpp index 62f00d0..369ab40 100644 --- a/06_advanced_templates/06_10_crtp.cpp +++ b/06_advanced_templates/06_10_crtp.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/qEsshf7Yn #include template From 7a621e62d3f816f69a568fa1377aae75ade629ee Mon Sep 17 00:00:00 2001 From: Moritz Perschke Date: Thu, 13 Mar 2025 16:58:09 +0100 Subject: [PATCH 7/9] added godbolt links to chapter 07 --- 07_concepts/07_01_basic_sample.cpp | 1 + 07_concepts/07_02_syntax_options.cpp | 1 + 07_concepts/07_03_constrained_auto.cpp | 2 +- 07_concepts/07_04_requires_expression.cpp | 2 +- 07_concepts/07_05_requirements.cpp | 1 + 07_concepts/07_06_dispatch.cpp | 1 + 07_concepts/07_07_partial_order.cpp | 3 ++- 7 files changed, 8 insertions(+), 3 deletions(-) diff --git a/07_concepts/07_01_basic_sample.cpp b/07_concepts/07_01_basic_sample.cpp index 2b15551..8c6f43b 100644 --- a/07_concepts/07_01_basic_sample.cpp +++ b/07_concepts/07_01_basic_sample.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/o44je9ohx #include #include #include diff --git a/07_concepts/07_02_syntax_options.cpp b/07_concepts/07_02_syntax_options.cpp index 0829a58..6d56925 100644 --- a/07_concepts/07_02_syntax_options.cpp +++ b/07_concepts/07_02_syntax_options.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/dvfxY6szs #include #include #include diff --git a/07_concepts/07_03_constrained_auto.cpp b/07_concepts/07_03_constrained_auto.cpp index 6958f64..64c076e 100644 --- a/07_concepts/07_03_constrained_auto.cpp +++ b/07_concepts/07_03_constrained_auto.cpp @@ -1,4 +1,4 @@ -// note: this is currently not supported in MSVC 16.8 +// https://godbolt.org/z/Wjzo9rxjv #include #include diff --git a/07_concepts/07_04_requires_expression.cpp b/07_concepts/07_04_requires_expression.cpp index ffbfa98..91bdbe7 100644 --- a/07_concepts/07_04_requires_expression.cpp +++ b/07_concepts/07_04_requires_expression.cpp @@ -1,4 +1,4 @@ - +// https://godbolt.org/z/PErGq4E8o // basic requires expression in a concept definition template concept Addable = requires(T x) { diff --git a/07_concepts/07_05_requirements.cpp b/07_concepts/07_05_requirements.cpp index 3ec046e..9d10b9e 100644 --- a/07_concepts/07_05_requirements.cpp +++ b/07_concepts/07_05_requirements.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/WWo5z3ToE #include #include diff --git a/07_concepts/07_06_dispatch.cpp b/07_concepts/07_06_dispatch.cpp index aa16eba..0a82f61 100644 --- a/07_concepts/07_06_dispatch.cpp +++ b/07_concepts/07_06_dispatch.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/Ph4M7ezaz #include /// Scenario: ///////////////////////////////////////////////////////////////// diff --git a/07_concepts/07_07_partial_order.cpp b/07_concepts/07_07_partial_order.cpp index 3b2b2db..6b11caa 100644 --- a/07_concepts/07_07_partial_order.cpp +++ b/07_concepts/07_07_partial_order.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/fGa1GWf3j #include template @@ -52,4 +53,4 @@ void test3() { int main() { test1(); test2(); -} \ No newline at end of file +} From f2c3bc41c3bde438b75f801f3829ab293d02667a Mon Sep 17 00:00:00 2001 From: Moritz Perschke Date: Thu, 13 Mar 2025 16:59:29 +0100 Subject: [PATCH 8/9] added godbolt links to chapter 08 I couldn't get examples 08 and 09 (program options and log) to compile on godbolt, so they didn't get links --- 08_libraries/08_01_regex.cpp | 1 + 08_libraries/08_02_threads.cpp | 1 + 08_libraries/08_03_future_fs.cpp | 1 + 08_libraries/08_04_boost_format.cpp | 2 +- 08_libraries/08_05_boost_bimap.cpp | 2 +- 08_libraries/08_06_boost_operators.cpp | 1 + 08_libraries/08_07_boost_hana.cpp | 1 + 08_libraries/08_10_eigen.cpp | 1 + 8 files changed, 8 insertions(+), 2 deletions(-) diff --git a/08_libraries/08_01_regex.cpp b/08_libraries/08_01_regex.cpp index e9b899f..99f8db5 100644 --- a/08_libraries/08_01_regex.cpp +++ b/08_libraries/08_01_regex.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/5TGhEzhn8 #include #include #include diff --git a/08_libraries/08_02_threads.cpp b/08_libraries/08_02_threads.cpp index 9d8c651..29b7080 100644 --- a/08_libraries/08_02_threads.cpp +++ b/08_libraries/08_02_threads.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/j4EnEaeGG #include #include #include diff --git a/08_libraries/08_03_future_fs.cpp b/08_libraries/08_03_future_fs.cpp index 9026c65..416450e 100644 --- a/08_libraries/08_03_future_fs.cpp +++ b/08_libraries/08_03_future_fs.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/5T7E4W45r #include #include #include diff --git a/08_libraries/08_04_boost_format.cpp b/08_libraries/08_04_boost_format.cpp index b6a5099..77b9819 100644 --- a/08_libraries/08_04_boost_format.cpp +++ b/08_libraries/08_04_boost_format.cpp @@ -1,5 +1,5 @@ // adapted from boost::format example - +// https://godbolt.org/z/YzPdWz779 #include #include #include diff --git a/08_libraries/08_05_boost_bimap.cpp b/08_libraries/08_05_boost_bimap.cpp index 2bc5c7e..54b3f16 100644 --- a/08_libraries/08_05_boost_bimap.cpp +++ b/08_libraries/08_05_boost_bimap.cpp @@ -1,5 +1,5 @@ // adapted from boost::bimap example - +// https://godbolt.org/z/zvzWTnvEP #include #include diff --git a/08_libraries/08_06_boost_operators.cpp b/08_libraries/08_06_boost_operators.cpp index caf1c43..feb5b9b 100644 --- a/08_libraries/08_06_boost_operators.cpp +++ b/08_libraries/08_06_boost_operators.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/aWMo3rfK7 #include #include #include diff --git a/08_libraries/08_07_boost_hana.cpp b/08_libraries/08_07_boost_hana.cpp index 4b62d7e..0c4c59b 100644 --- a/08_libraries/08_07_boost_hana.cpp +++ b/08_libraries/08_07_boost_hana.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/T6jcb81ja #include /// Scenario: ///////////////////////////////////////////////////////////////// diff --git a/08_libraries/08_10_eigen.cpp b/08_libraries/08_10_eigen.cpp index f0ffe8c..5e26a4a 100644 --- a/08_libraries/08_10_eigen.cpp +++ b/08_libraries/08_10_eigen.cpp @@ -1,3 +1,4 @@ +// https://godbolt.org/z/4Kr1991fh #include #include From b44c6463ef7ab32cb45489053c617ab144b5b532 Mon Sep 17 00:00:00 2001 From: Moritz Perschke Date: Wed, 2 Apr 2025 15:54:48 +0200 Subject: [PATCH 9/9] compiler explorer links updated - previously forgot to change flags on some non-executor compilers, which left squigglies in the editor part - library examples now show clang + gcc output --- 03_lambdas_and_algorithms/03_07_lambda_implementation.cpp | 2 +- 03_lambdas_and_algorithms/03_09_exec_policy_bench.cpp | 2 +- 04_templates/04_07_class_template_arg_deduction.cpp | 2 +- 05_keyword_safari/05_04_static_members.cpp | 2 +- 05_keyword_safari/05_07_mutable_data_members.cpp | 2 +- 05_keyword_safari/05_09_constevalinit.cpp | 2 +- 06_advanced_templates/06_03_type_result.cpp | 2 +- 06_advanced_templates/06_07_dispatch.cpp | 2 +- 07_concepts/07_01_basic_sample.cpp | 2 +- 07_concepts/07_02_syntax_options.cpp | 2 +- 07_concepts/07_03_constrained_auto.cpp | 2 +- 07_concepts/07_04_requires_expression.cpp | 2 +- 07_concepts/07_05_requirements.cpp | 2 +- 07_concepts/07_06_dispatch.cpp | 2 +- 07_concepts/07_07_partial_order.cpp | 2 +- 08_libraries/08_02_threads.cpp | 2 +- 08_libraries/08_04_boost_format.cpp | 2 +- 08_libraries/08_05_boost_bimap.cpp | 2 +- 08_libraries/08_06_boost_operators.cpp | 2 +- 08_libraries/08_07_boost_hana.cpp | 2 +- 08_libraries/08_10_eigen.cpp | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) diff --git a/03_lambdas_and_algorithms/03_07_lambda_implementation.cpp b/03_lambdas_and_algorithms/03_07_lambda_implementation.cpp index 90da76e..83ba427 100644 --- a/03_lambdas_and_algorithms/03_07_lambda_implementation.cpp +++ b/03_lambdas_and_algorithms/03_07_lambda_implementation.cpp @@ -1,4 +1,4 @@ -// https://godbolt.org/z/W3T5oG5sc +// https://godbolt.org/z/eWhKPhPPG #include void test1() { diff --git a/03_lambdas_and_algorithms/03_09_exec_policy_bench.cpp b/03_lambdas_and_algorithms/03_09_exec_policy_bench.cpp index 6e28732..82d532b 100644 --- a/03_lambdas_and_algorithms/03_09_exec_policy_bench.cpp +++ b/03_lambdas_and_algorithms/03_09_exec_policy_bench.cpp @@ -1,5 +1,5 @@ // g++ main.cpp -O3 -std=c++20 -ltbb -Wall -Wextra -o main -// https://godbolt.org/z/jso53sM1o +// https://godbolt.org/z/xfPWd8orh #include #include #include diff --git a/04_templates/04_07_class_template_arg_deduction.cpp b/04_templates/04_07_class_template_arg_deduction.cpp index 00b5b89..4dd5d18 100644 --- a/04_templates/04_07_class_template_arg_deduction.cpp +++ b/04_templates/04_07_class_template_arg_deduction.cpp @@ -1,5 +1,5 @@ // you can see this example working with recent GCC and Clang versions here: -// https://godbolt.org/z/r6Ysq4dPe +// https://godbolt.org/z/xvnxjcnK9 #include #include diff --git a/05_keyword_safari/05_04_static_members.cpp b/05_keyword_safari/05_04_static_members.cpp index b0702ff..f1f4008 100644 --- a/05_keyword_safari/05_04_static_members.cpp +++ b/05_keyword_safari/05_04_static_members.cpp @@ -1,4 +1,4 @@ -// https://godbolt.org/z/GvqvYEW1o +// https://godbolt.org/z/bsTfzEzan #include struct Foo { diff --git a/05_keyword_safari/05_07_mutable_data_members.cpp b/05_keyword_safari/05_07_mutable_data_members.cpp index 793e0ad..eb9f36e 100644 --- a/05_keyword_safari/05_07_mutable_data_members.cpp +++ b/05_keyword_safari/05_07_mutable_data_members.cpp @@ -1,4 +1,4 @@ -// https://godbolt.org/z/43GhsYxnc + class ComplexShape { mutable bool volumeCalculated = false; mutable double volume; diff --git a/05_keyword_safari/05_09_constevalinit.cpp b/05_keyword_safari/05_09_constevalinit.cpp index 4876ec2..a2f5dea 100644 --- a/05_keyword_safari/05_09_constevalinit.cpp +++ b/05_keyword_safari/05_09_constevalinit.cpp @@ -1,5 +1,5 @@ // Sample adapted from cppreference -// Available in compiler explorer: https://godbolt.org/z/oKf63hzaE +// https://godbolt.org/z/zKhYaf33q #include diff --git a/06_advanced_templates/06_03_type_result.cpp b/06_advanced_templates/06_03_type_result.cpp index 3246f38..e08ac97 100644 --- a/06_advanced_templates/06_03_type_result.cpp +++ b/06_advanced_templates/06_03_type_result.cpp @@ -1,4 +1,4 @@ -// https://godbolt.org/z/K5Whq6Es4 +// https://godbolt.org/z/PdP48h9ET #include #include diff --git a/06_advanced_templates/06_07_dispatch.cpp b/06_advanced_templates/06_07_dispatch.cpp index 57f3b8e..161bbf8 100644 --- a/06_advanced_templates/06_07_dispatch.cpp +++ b/06_advanced_templates/06_07_dispatch.cpp @@ -1,4 +1,4 @@ -// https://godbolt.org/z/Yx5G1zsME +// https://godbolt.org/z/sdW5894xe #include /// Scenario: ///////////////////////////////////////////////////////////////// diff --git a/07_concepts/07_01_basic_sample.cpp b/07_concepts/07_01_basic_sample.cpp index 8c6f43b..4bb6ce2 100644 --- a/07_concepts/07_01_basic_sample.cpp +++ b/07_concepts/07_01_basic_sample.cpp @@ -1,4 +1,4 @@ -// https://godbolt.org/z/o44je9ohx +// https://godbolt.org/z/To89f71M4 #include #include #include diff --git a/07_concepts/07_02_syntax_options.cpp b/07_concepts/07_02_syntax_options.cpp index 6d56925..6c2ce5e 100644 --- a/07_concepts/07_02_syntax_options.cpp +++ b/07_concepts/07_02_syntax_options.cpp @@ -1,4 +1,4 @@ -// https://godbolt.org/z/dvfxY6szs +// https://godbolt.org/z/GsE1rvqnT #include #include #include diff --git a/07_concepts/07_03_constrained_auto.cpp b/07_concepts/07_03_constrained_auto.cpp index 64c076e..1a67150 100644 --- a/07_concepts/07_03_constrained_auto.cpp +++ b/07_concepts/07_03_constrained_auto.cpp @@ -1,4 +1,4 @@ -// https://godbolt.org/z/Wjzo9rxjv +// https://godbolt.org/z/WPGscxPdo #include #include diff --git a/07_concepts/07_04_requires_expression.cpp b/07_concepts/07_04_requires_expression.cpp index 91bdbe7..3638d06 100644 --- a/07_concepts/07_04_requires_expression.cpp +++ b/07_concepts/07_04_requires_expression.cpp @@ -1,4 +1,4 @@ -// https://godbolt.org/z/PErGq4E8o +// https://godbolt.org/z/WYEoW5bzz // basic requires expression in a concept definition template concept Addable = requires(T x) { diff --git a/07_concepts/07_05_requirements.cpp b/07_concepts/07_05_requirements.cpp index 9d10b9e..9f590aa 100644 --- a/07_concepts/07_05_requirements.cpp +++ b/07_concepts/07_05_requirements.cpp @@ -1,4 +1,4 @@ -// https://godbolt.org/z/WWo5z3ToE +// https://godbolt.org/z/75q59E7cv #include #include diff --git a/07_concepts/07_06_dispatch.cpp b/07_concepts/07_06_dispatch.cpp index 0a82f61..7bf2615 100644 --- a/07_concepts/07_06_dispatch.cpp +++ b/07_concepts/07_06_dispatch.cpp @@ -1,4 +1,4 @@ -// https://godbolt.org/z/Ph4M7ezaz +// https://godbolt.org/z/xdEssa3bP #include /// Scenario: ///////////////////////////////////////////////////////////////// diff --git a/07_concepts/07_07_partial_order.cpp b/07_concepts/07_07_partial_order.cpp index 6b11caa..5d393a2 100644 --- a/07_concepts/07_07_partial_order.cpp +++ b/07_concepts/07_07_partial_order.cpp @@ -1,4 +1,4 @@ -// https://godbolt.org/z/fGa1GWf3j +// https://godbolt.org/z/6c5r537e5 #include template diff --git a/08_libraries/08_02_threads.cpp b/08_libraries/08_02_threads.cpp index 29b7080..7d28c93 100644 --- a/08_libraries/08_02_threads.cpp +++ b/08_libraries/08_02_threads.cpp @@ -1,4 +1,4 @@ -// https://godbolt.org/z/j4EnEaeGG +// https://godbolt.org/z/81cd58Wxr #include #include #include diff --git a/08_libraries/08_04_boost_format.cpp b/08_libraries/08_04_boost_format.cpp index 77b9819..9ee6c8c 100644 --- a/08_libraries/08_04_boost_format.cpp +++ b/08_libraries/08_04_boost_format.cpp @@ -1,5 +1,5 @@ // adapted from boost::format example -// https://godbolt.org/z/YzPdWz779 +// https://godbolt.org/z/3q169Eoa7 #include #include #include diff --git a/08_libraries/08_05_boost_bimap.cpp b/08_libraries/08_05_boost_bimap.cpp index 54b3f16..f7e70ab 100644 --- a/08_libraries/08_05_boost_bimap.cpp +++ b/08_libraries/08_05_boost_bimap.cpp @@ -1,5 +1,5 @@ // adapted from boost::bimap example -// https://godbolt.org/z/zvzWTnvEP +// https://godbolt.org/z/7Mor8P46z #include #include diff --git a/08_libraries/08_06_boost_operators.cpp b/08_libraries/08_06_boost_operators.cpp index feb5b9b..4f93fd9 100644 --- a/08_libraries/08_06_boost_operators.cpp +++ b/08_libraries/08_06_boost_operators.cpp @@ -1,4 +1,4 @@ -// https://godbolt.org/z/aWMo3rfK7 +// https://godbolt.org/z/WGqhjGWd4 #include #include #include diff --git a/08_libraries/08_07_boost_hana.cpp b/08_libraries/08_07_boost_hana.cpp index 0c4c59b..7005c6f 100644 --- a/08_libraries/08_07_boost_hana.cpp +++ b/08_libraries/08_07_boost_hana.cpp @@ -1,4 +1,4 @@ -// https://godbolt.org/z/T6jcb81ja +// https://godbolt.org/z/erGf1bbx9 #include /// Scenario: ///////////////////////////////////////////////////////////////// diff --git a/08_libraries/08_10_eigen.cpp b/08_libraries/08_10_eigen.cpp index 5e26a4a..31d5bb1 100644 --- a/08_libraries/08_10_eigen.cpp +++ b/08_libraries/08_10_eigen.cpp @@ -1,4 +1,4 @@ -// https://godbolt.org/z/4Kr1991fh +// https://godbolt.org/z/erGf1bbx9 #include #include