← 返回
效率工具 中文

C++

Avoid common C++ mistakes — memory leaks, dangling references, undefined behavior, and ownership confusion.
"空空如也"
ivangdavila
效率工具 clawhub v1.0.1 1 版本 99791.3 Key: 无需
★ 3
Stars
📥 1,853
下载
💾 197
安装
1
版本
#latest

概述

Quick Reference

TopicFile
-------------
RAII, smart pointers, new/deletememory.md
Raw pointers, references, nullptrpointers.md
Rule of 3/5/0, inheritance, virtualclasses.md
Containers, iterators, algorithmsstl.md
Templates, SFINAE, conceptstemplates.md
Threads, mutex, atomicsconcurrency.md
C++11/14/17/20, move semanticsmodern.md
Undefined behavior trapsub.md

Critical Rules

  • Raw new without delete leaks — use std::unique_ptr or std::make_unique
  • Returning reference to local — undefined behavior, object destroyed on return
  • == for C-strings compares pointers — use std::string or strcmp()
  • Signed integer overflow is UB — not wrap-around like unsigned
  • Virtual destructor required in base class — otherwise derived destructor skipped
  • std::move doesn't move — it casts to rvalue, enabling move semantics
  • Moved-from object valid but unspecified — don't use without reassigning
  • Data race on non-atomic is UB — use std::mutex or std::atomic
  • vector is not a real container — returns proxy, use deque
  • map[key] inserts default if missing — use find() or contains() to check
  • Braced init {} prevents narrowing — int x{3.5} errors, int x(3.5) truncates
  • Iterator invalidation on push_back — vector may relocate, invalidating iterators
  • string_view doesn't own data — underlying string must outlive the view

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-03-28 22:55 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

productivity

Word / DOCX

ivangdavila
创建、检查和编辑 Microsoft Word 文档及 DOCX 文件,支持样式、编号、修订记录、表格、分节符及兼容性检查等功能。
★ 438 📥 147,485
ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,356 📥 318,069
productivity

Weather

steipete
获取当前天气和预报(无需API密钥)
★ 445 📥 226,232