throwing_ptr:仅标头的库包装标准

时间:2021-05-13 00:52:09
【文件属性】:
文件名称:throwing_ptr:仅标头的库包装标准
文件大小:83KB
文件格式:ZIP
更新时间:2021-05-13 00:52:09
cpp cpp11 cpp-library C++ 投掷智能指针 仅标头的库,包装和 ,当取消包装的空指针被引用时引发异常 基本原理 取消引用空标准智能指针是未定义的行为,可能导致程序崩溃。 该库旨在完全复制包装的标准智能指针的行为,但有一个例外(sic),即在调用->,*和[]运算符时将抛出一个例外。 可以以特定于应用程序的方式捕获和处理此类异常(例如,通过显示错误弹出窗口) 该库可能有用的情况: 使用自定义智能指针类的旧版代码在取消引用后抛出:此库提供了逐步过渡到标准智能指针的途径。 此类代码可能取决于抛出的行为,从而容易产生直接迁移错误。 对null解除引用错误的适应能力很重要的程序,例如GUI 使用此库的成本很明显,因为每个取消引用都会添加一个分支。 在这些情况下,库公开了底层的标准智能指针,并且用户可能会选择在不注意取消引用空指针的热代码路径中使用该智能指针。 设计决策 该库依靠std :: shared_ptr和std
【文件预览】:
throwing_ptr-master
----.travis.yml(2KB)
----build.py(2KB)
----tests()
--------unique_ptr_to_array_assignment_from_convertible.cpp(2KB)
--------unique_ptr_swap.cpp(2KB)
--------compile_it.cpp(485B)
--------unique_ptr_to_array_assignment.cpp(1KB)
--------shared_ptr_assignment.cpp(2KB)
--------unique_ptr_comparison.cpp(6KB)
--------shared_ptr_ostream.cpp(810B)
--------shared_ptr_comparison.cpp(6KB)
--------weak_ptr_observers.cpp(2KB)
--------shared_ptr_access.cpp(3KB)
--------weak_ptr_modifiers.cpp(1KB)
--------unique_ptr_hash.cpp(498B)
--------unique_ptr_assignment.cpp(2KB)
--------unique_ptr_make_unique.cpp(1KB)
--------shared_ptr_swap.cpp(1KB)
--------test_main.cpp(261B)
--------compile_fail()
--------shared_ptr_reset.cpp(3KB)
--------shared_ptr_ordering.cpp(750B)
--------unique_ptr_to_array_construction.cpp(7KB)
--------shared_ptr_make_shared.cpp(2KB)
--------unique_ptr_construction.cpp(8KB)
--------unique_ptr_to_array_reset.cpp(957B)
--------shared_ptr_cast.cpp(2KB)
--------shared_ptr_to_array.cpp(1KB)
--------unique_ptr_dereference.cpp(2KB)
--------shared_ptr_enable_shared_from_this.cpp(1023B)
--------unique_ptr_reset.cpp(2KB)
--------unique_ptr_to_array_access.cpp(2KB)
--------weak_ptr_construction.cpp(2KB)
--------shared_ptr_hash.cpp(525B)
--------shared_ptr_atomic.cpp(4KB)
--------unique_ptr_ostream.cpp(1KB)
--------test_helpers.h(856B)
--------weak_ptr_assignment.cpp(3KB)
--------unique_ptr_release.cpp(1KB)
--------shared_ptr_construction.cpp(7KB)
--------unique_ptr_access.cpp(783B)
----include()
--------throwing()
----LICENSE(1KB)
----Doxyfile(105KB)
----appveyor.yml(1KB)
----.clang-format(3KB)
----conanfile.py(793B)
----.gitignore(35B)
----CMakeLists.txt(6KB)
----.travis()
--------install.sh(549B)
--------run.sh(226B)
----README.md(5KB)

网友评论