Template Function TRAP::MakeUniqueResourceChecked#
Function Documentation#
-
template<typename Resource, typename Deleter, typename Sentinel = std::decay_t<Resource>>
constexpr UniqueResource<std::decay_t<Resource>, std::decay_t<Deleter>> TRAP::MakeUniqueResourceChecked(Resource &&r, const Sentinel &invalid, Deleter &&d) noexcept(std::is_nothrow_constructible_v<std::decay_t<Resource>, Resource> && std::is_nothrow_constructible_v<std::decay_t<Deleter>, Deleter>)# Creates a UniqueResource, its stored resource handle is initialized with std::forward<Resource>(r) and its deleter with std::forward<Deleter>(d). The created UniqueResource owns the resource if and only if bool(r == invalid) is false.
Note
MakeUniqueResourceChecked() exists to avoid calling a deleter function with an invalid argument.
- Parameters:
r – A resource handle.
invalid – A value indicating the resource handle is invalid.
d – A deleter to use to dispose the resource.
- Returns:
A UniqueResource as described above.