| name | C++ Ecosystem |
| description | This skill should be used when working with C++ projects, CMakeLists.txt, Ninja, clang-tidy, clang-format, GoogleTest, Catch2, or Modern C++ (C++11-23) language patterns. Provides comprehensive C++ ecosystem patterns and best practices. |
template<Addable T> T add(T a, T b) { return a + b; }
// main.cpp import math; int main() { return add(1, 2); }
generator<int> range(int start, int end) { for (int i = start; i < end; ++i) { co_yield i; } }
task<int> async_compute() { co_return co_await some_async_operation(); }
// Automatically generates ==, !=, <, >, <=, >=
std::variant<int, std::string, double> data = 42; std::visit([](auto&& val) { std::cout << val; }, data);
auto future = std::async(std::launch::async, []{ return 42; }); int result = future.get();
std::shared_mutex rw_mtx; std::shared_lock<std::shared_mutex> read_lock(rw_mtx); // multiple readers std::unique_lock<std::shared_mutex> write_lock(rw_mtx); // exclusive writer
// Waiting thread std::unique_lock<std::mutex> lock(mtx); cv.wait(lock, []{ return ready; });
// Notifying thread { std::lock_guard<std::mutex> lock(mtx); ready = true; } cv.notify_one();
// source class Widget::Impl { // implementation details };
class Derived : public Base<Derived> { public: void implementation() { /_ ... _/ } };
<projectstructure>
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF)
add_library(mylib STATIC src/mylib.cpp) target_include_directories(mylib PUBLIC include) target_compile_features(mylib PUBLIC cxx_std_20)
add_executable(myapp src/main.cpp) target_link_libraries(myapp PRIVATE mylib)
target_link_libraries(myapp PRIVATE Threads::Threads) target_link_libraries(mytests PRIVATE GTest::gtest GTest::gtest_main)
WarningsAsErrors: '' HeaderFilterRegex: '.'
CheckOptions:
- key: readability-identifier-naming.ClassCase value: CamelCase
- key: readability-identifier-naming.FunctionCase value: camelBack
- key: readability-identifier-naming.VariableCase value: lower_case
<clangformat>
CMakePresets.json sanitizer configuration
{ "configurePresets": [{ "name": "sanitize", "cacheVariables": { "CMAKE_CXX_FLAGS": "-fsanitize=address,undefined -fno-omit-frame-pointer" } }] }
add_executable(tests tests/test_main.cpp) target_link_libraries(tests PRIVATE GTest::gtest GTest::gtest_main)
include(GoogleTest) gtest_discover_tests(tests)
TEST(MyTest, BasicAssertion) { EXPECT_EQ(1 + 1, 2); }
TEST(MyTest, StringComparison) { std::string s = "hello"; EXPECT_STREQ(s.c_str(), "hello"); }
class MyFixture : public ::testing::Test { protected: void SetUp() override { /_ setup / } void TearDown() override { / cleanup _/ } };
TEST_F(MyFixture, FixtureTest) { EXPECT_TRUE(true); }
add_executable(tests tests/test_main.cpp) target_link_libraries(tests PRIVATE Catch2::Catch2WithMain)
include(CTest) include(Catch) catch_discover_tests(tests)
TEST_CASE("Basic arithmetic", "[math]") { REQUIRE(1 + 1 == 2); CHECK(2 * 2 == 4); }
TEST_CASE("String operations", "[string]") { std::string s = "hello";
SECTION("length") {
REQUIRE(s.length() == 5);
}
SECTION("comparison") {
REQUIRE(s == "hello");
}
}