Production-grade skill for modern C++ development with C++11 through C++23 features. Covers move semantics, smart pointers, lambdas, concepts, ranges, coroutines, and modules.
Standardmäßig ist der Prompt ausgewählt, der zuerst die Quelle prüft. Sie können zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.
Quelldateien prüfen
Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich für eine Installation entscheiden.
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Ein direkter Befehl überspringt den Prüf-Prompt. Prüfen Sie die Quelle, bevor Sie ihn ausführen.
Production-grade skill for modern C++ development with C++11 through C++23 features. Covers move semantics, smart pointers, lambdas, concepts, ranges, coroutines, and modules.
sasmp_version
1.3.0
skill_version
3.0.0
bonded_agent
01-modern-cpp-expert
bond_type
PRIMARY_BOND
category
development
parameters
{"cpp_standard":{"type":"string","required":false,"enum":["cpp11","cpp14","cpp17","cpp20","cpp23"],"default":"cpp20","description":"Target C++ standard version"},"feature_category":{"type":"string","required":false,"enum":["move_semantics","smart_pointers","lambdas","concepts","ranges","coroutines","modules"],"description":"Specific modern C++ feature to focus on"},"migration_mode":{"type":"boolean","required":false,"default":false,"description":"Whether migrating from legacy C++ code"}}
// lvalue: Has identity, can be addressedint x = 10; // x is lvalueint* p = &x; // Can take address// rvalue: Temporary, no persistent identityint y = x + 5; // (x + 5) is rvalue// int* p2 = &(x + 5); // Error: cannot take address// xvalue: eXpiring lvalue (about to be moved)
std::string s = "hello";
std::string t = std::move(s); // s is now xvalue
Need pointer?
├── Single owner? → std::unique_ptr
├── Shared ownership? → std::shared_ptr
│ └── Need to break cycles? → std::weak_ptr
├── Non-owning view? → raw pointer or reference
└── Polymorphic container? → std::unique_ptr<Base>
Lambda Expressions
Lambda Evolution
// C++11: Basic lambdaauto f1 = [](int x) { return x * 2; };
// C++14: Generic lambdaauto f2 = [](auto x) { return x * 2; };
// C++17: constexpr lambdaconstexprauto f3 = [](int x) constexpr { return x * 2; };
// C++20: Template lambdaauto f4 = []<typename T>(std::vector<T>& v) { v.clear(); };
// C++20: Lambda with explicit template paramsauto f5 = []<typename T>(T a, T b) { return a + b; };
// C++23: Deducing thisstructWidget {
autogetName(thisauto&& self){
return std::forward_like<decltype(self)>(self.name_);
}
};
Capture Modes
int x = 10;
std::string s = "hello";
// By valueauto f1 = [x]() { return x; };
// By referenceauto f2 = [&x]() { return x++; };
// Move capture (C++14)auto f3 = [s = std::move(s)]() { return s; };
// Init capture with expressionauto f4 = [y = x * 2]() { return y; };
// Capture all by valueauto f5 = [=]() { return x + s.size(); };
// Capture all by referenceauto f6 = [&]() { x++; };
// Mixedauto f7 = [=, &x]() { x++; return s; };
Concepts (C++20)
Standard Concepts
#include<concepts>// Using standard conceptstemplate<std::integral T>
T gcd(T a, T b){
while (b != 0) {
T t = b;
b = a % b;
a = t;
}
return a;
}
// Common conceptstemplate<std::floating_point T>
T sqrt(T x);
template<std::copyable T>
voidprocess(T value);
template<std::invocable<int> F>
voidapply(F&& func);
Use if-init: if (auto it = m.find(k); it != m.end())
Replace boost::optional with std::optional
Use std::string_view for read-only strings
Use [[nodiscard]] for important return values
From C++17 to C++20
Replace SFINAE with concepts
Use ranges instead of begin/end pairs
Consider modules for large projects
Use std::span for contiguous ranges
Use <=> spaceship operator
Use designated initializers
Troubleshooting Decision Tree
Compilation error with modern feature?
├── "requires C++XX or later"
│ └── Update -std=c++XX flag
├── "concept not satisfied"
│ ├── Check type requirements
│ └── Add missing operations to type
├── "move from const"
│ └── Remove const or copy instead
├── "use of deleted function"
│ ├── Check if type is movable
│ └── Use std::move if needed
└── "incomplete type in unique_ptr"
└── Define destructor in .cpp file