// // Tests for // pointer get() const noexcept; // #include #include "test_policy.h" #include #include struct T { int i; }; template static constexpr auto can_call_get_on_temporary(int)->decltype(std::declval >().get(), bool ()) { return true; } template static constexpr auto can_call_get_on_temporary(...)->bool { return false; } template static void tests() { { T obj{3}; tracking_policy::reset(); tracked_shared_ptr const ptr(&obj, libkern::retain); T* raw = ptr.get(); CHECK(raw == &obj); CHECK(ptr.get() == raw); // ptr didn't change CHECK(tracking_policy::retains == 1); CHECK(tracking_policy::releases == 0); } static_assert(!can_call_get_on_temporary(int{}), ""); } T_DECL(get, "intrusive_shared_ptr.get", T_META_TAG_VM_PREFERRED) { tests(); tests(); }