1#ifndef ENTT_RESOURCE_RESOURCE_HPP
2#define ENTT_RESOURCE_RESOURCE_HPP
21template<
typename Type>
24 friend class resource;
26 template<
typename Other>
27 static constexpr bool is_acceptable = !std::is_same_v<Type, Other> && std::is_constructible_v<Type &, Other &>;
44 : value{std::move(res)} {}
58 template<typename Other>
60 : value{other.value, std::addressof(res)} {}
67 template<
typename Other,
typename = std::enable_if_t<is_acceptable<Other>>>
68 resource(
const resource<Other> &other) noexcept
69 : value{other.value} {}
76 template<
typename Other,
typename = std::enable_if_t<is_acceptable<Other>>>
78 : value{std::move(other.value)} {}
87 resource &
operator=(
const resource &)
noexcept =
default;
93 resource &
operator=(resource &&) noexcept = default;
101 template<typename Other, typename = std::enable_if_t<is_acceptable<Other>>>
102 resource &operator=(const resource<Other> &other) noexcept {
113 template<
typename Other,
typename = std::enable_if_t<is_acceptable<Other>>>
115 value = std::move(other.value);
123 void swap(resource &other)
noexcept {
125 swap(value, other.value);
157 [[nodiscard]]
explicit operator bool() const noexcept {
158 return static_cast<bool>(value);
171 value = std::move(other);
194template<
typename Lhs,
typename Rhs>
196 return (std::addressof(*lhs) == std::addressof(*rhs));
207template<
typename Lhs,
typename Rhs>
209 return !(lhs == rhs);
220template<
typename Lhs,
typename Rhs>
222 return (std::addressof(*lhs) < std::addressof(*rhs));
233template<
typename Lhs,
typename Rhs>
247template<
typename Lhs,
typename Rhs>
261template<
typename Lhs,
typename Rhs>
resource(const resource< Other > &other) noexcept
Copy constructs a handle which shares ownership of the resource.
Type element_type
Resource type.
resource(const resource &) noexcept=default
Default copy constructor.
resource & operator=(resource< Other > &&other) noexcept
Move assignment operator from foreign handle.
element_type & operator*() const noexcept
Returns a reference to the managed resource.
const handle_type & handle() const noexcept
Returns the underlying resource handle.
resource & operator=(const resource &) noexcept=default
Default copy assignment operator.
element_type * operator->() const noexcept
Returns a pointer to the managed resource.
void reset(handle_type other)
Replaces the managed resource.
void reset()
Releases the ownership of the managed resource.
resource & operator=(resource &&) noexcept=default
Default move assignment operator.
resource(handle_type res) noexcept
Creates a new resource handle.
void swap(resource &other) noexcept
Exchanges the content with that of a given resource.
resource() noexcept
Default constructor.
~resource()=default
Default destructor.
std::shared_ptr< element_type > handle_type
Handle type.
resource(resource< Other > &&other) noexcept
Move constructs a handle which takes ownership of the resource.
resource(resource &&) noexcept=default
Default move constructor.
constexpr bool operator<=(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) noexcept
Compares two hashed strings.
constexpr bool operator<(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) noexcept
Compares two hashed strings.
constexpr bool operator!=(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) noexcept
Compares two hashed strings.
constexpr bool operator>=(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) noexcept
Compares two hashed strings.
constexpr bool operator>(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) noexcept
Compares two hashed strings.
constexpr bool operator==(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) noexcept
Compares two hashed strings.