Browse Source

Delete access added.

main
offa 7 years ago
parent
commit
73748ae3ff
2 changed files with 17 additions and 0 deletions
  1. +6
    -0
      include/unique_resource.h
  2. +11
    -0
      test/UniqueResourceTest.cpp

+ 6
- 0
include/unique_resource.h View File

} }




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


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

+ 11
- 0
test/UniqueResourceTest.cpp View File

REQUIRE(ref == 3); 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);

}

Loading…
Cancel
Save