y3c-stl 0.3.3
Friendly C++ STL wrapper with automatic stacktrace
Loading...
Searching...
No Matches
shared_ptr-ref.cc

‍example output:

100
y3c-stl terminated: undefined behavior detected (ub_access_deleted)
at cast from y3c::wrap<int&> to reference: attempted to access the deleted value.
Stack trace (most recent call first):
#0 0x000055d498d10722 in main at /home/runner/work/y3c-stl/y3c-stl/build/../examples/shared_ptr-ref.cc:9:18
7: std::cout << ref << std::endl;
8: a.reset();
9: std::cout << ref << std::endl;
10: }
値型wrap: base_type型のデータと、このデータの生存状態を管理するクラス
Definition wrap.h:26
Definition array.h:8
#include <y3c/memory>
#include <iostream>
int main() {
y3c::shared_ptr<int> a = std::make_shared<int>(100);
std::cout << ref << std::endl;
a.reset();
std::cout << ref << std::endl;
}
所有権を共有するスマートポインタ (std::shared_ptr)
Definition shared_ptr.h:28
void reset() noexcept
所有権を放棄
Definition shared_ptr.h:152
参照型wrap: element_type型のデータへの参照を持つクラス
Definition wrap.h:168