浏览代码

Delete access added.

main
offa 7 年前
父节点
当前提交
73748ae3ff
共有 2 个文件被更改,包括 17 次插入0 次删除
  1. +6
    -0
      include/unique_resource.h
  2. +11
    -0
      test/UniqueResourceTest.cpp

+ 6
- 0
include/unique_resource.h 查看文件

@@ -91,6 +91,12 @@ namespace sr
}


const Deleter& get_deleter() const noexcept
{
return m_deleter;
}


unique_resource_t& operator=(unique_resource_t&& other) noexcept
{
invoke(invoke_it::once);

+ 11
- 0
test/UniqueResourceTest.cpp 查看文件

@@ -256,3 +256,14 @@ TEST_CASE("conversion operator accesses ressource", "[UniqueResource]")
REQUIRE(ref == 3);
}

// TODO: conditional access functions

TEST_CASE("deleter access", "[UniqueResource]")
{
std::size_t value{0};
auto guard = sr::unique_resource(Handle{3}, [&value](auto v) { value = v; });
REQUIRE(value == 0);
guard.get_deleter()(6);
REQUIRE(value == 6);

}

正在加载...
取消
保存