meta: [[nodiscard]]
This commit is contained in:
@@ -21,8 +21,8 @@ struct meta_type_node;
|
||||
struct meta_context {
|
||||
dense_map<id_type, meta_type_node, identity> value{};
|
||||
|
||||
static inline meta_context &from(meta_ctx &ctx);
|
||||
static inline const meta_context &from(const meta_ctx &ctx);
|
||||
[[nodiscard]] static inline meta_context &from(meta_ctx &ctx);
|
||||
[[nodiscard]] static inline const meta_context &from(const meta_ctx &ctx);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
@@ -49,11 +49,11 @@ class meta_ctx: private internal::meta_context {
|
||||
* Internal details not to be documented.
|
||||
*/
|
||||
|
||||
inline internal::meta_context &internal::meta_context::from(meta_ctx &ctx) {
|
||||
[[nodiscard]] inline internal::meta_context &internal::meta_context::from(meta_ctx &ctx) {
|
||||
return ctx;
|
||||
}
|
||||
|
||||
inline const internal::meta_context &internal::meta_context::from(const meta_ctx &ctx) {
|
||||
[[nodiscard]] inline const internal::meta_context &internal::meta_context::from(const meta_ctx &ctx) {
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace entt {
|
||||
|
||||
namespace internal {
|
||||
|
||||
inline decltype(auto) owner(meta_ctx &ctx, const type_info &info) {
|
||||
[[nodiscard]] inline decltype(auto) owner(meta_ctx &ctx, const type_info &info) {
|
||||
auto &&context = internal::meta_context::from(ctx);
|
||||
ENTT_ASSERT(context.value.contains(info.hash()), "Type not available");
|
||||
return context.value[info.hash()];
|
||||
|
||||
@@ -613,7 +613,7 @@ private:
|
||||
* @return A properly initialized and not necessarily owning wrapper.
|
||||
*/
|
||||
template<typename Type>
|
||||
meta_any forward_as_meta(const meta_ctx &ctx, Type &&value) {
|
||||
[[nodiscard]] meta_any forward_as_meta(const meta_ctx &ctx, Type &&value) {
|
||||
return meta_any{ctx, std::in_place_type<Type &&>, std::forward<Type>(value)};
|
||||
}
|
||||
|
||||
@@ -624,7 +624,7 @@ meta_any forward_as_meta(const meta_ctx &ctx, Type &&value) {
|
||||
* @return A properly initialized and not necessarily owning wrapper.
|
||||
*/
|
||||
template<typename Type>
|
||||
meta_any forward_as_meta(Type &&value) {
|
||||
[[nodiscard]] meta_any forward_as_meta(Type &&value) {
|
||||
return forward_as_meta(locator<meta_ctx>::value_or(), std::forward<Type>(value));
|
||||
}
|
||||
|
||||
@@ -1348,12 +1348,12 @@ public:
|
||||
* @param element A valid pointer to an element of the underlying type.
|
||||
* @return A wrapper that references the given instance.
|
||||
*/
|
||||
meta_any from_void(void *element) const {
|
||||
[[nodiscard]] meta_any from_void(void *element) const {
|
||||
return (element && node.from_void) ? node.from_void(*ctx, element, nullptr) : meta_any{meta_ctx_arg, *ctx};
|
||||
}
|
||||
|
||||
/*! @copydoc from_void */
|
||||
meta_any from_void(const void *element) const {
|
||||
[[nodiscard]] meta_any from_void(const void *element) const {
|
||||
return (element && node.from_void) ? node.from_void(*ctx, nullptr, element) : meta_any{meta_ctx_arg, *ctx};
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ using meta_function_helper_t = typename meta_function_helper<Type, Candidate>::t
|
||||
* @return A meta any containing the returned value, if any.
|
||||
*/
|
||||
template<typename Policy = as_is_t, typename Type>
|
||||
std::enable_if_t<is_meta_policy_v<Policy>, meta_any> meta_dispatch(const meta_ctx &ctx, [[maybe_unused]] Type &&value) {
|
||||
[[nodiscard]] std::enable_if_t<is_meta_policy_v<Policy>, meta_any> meta_dispatch(const meta_ctx &ctx, [[maybe_unused]] Type &&value) {
|
||||
if constexpr(std::is_same_v<Policy, as_void_t>) {
|
||||
return meta_any{ctx, std::in_place_type<void>};
|
||||
} else if constexpr(std::is_same_v<Policy, as_ref_t>) {
|
||||
@@ -183,7 +183,7 @@ std::enable_if_t<is_meta_policy_v<Policy>, meta_any> meta_dispatch(const meta_ct
|
||||
* @return A meta any containing the returned value, if any.
|
||||
*/
|
||||
template<typename Policy = as_is_t, typename Type>
|
||||
std::enable_if_t<is_meta_policy_v<Policy>, meta_any> meta_dispatch(Type &&value) {
|
||||
[[nodiscard]] std::enable_if_t<is_meta_policy_v<Policy>, meta_any> meta_dispatch(Type &&value) {
|
||||
return meta_dispatch<Policy, Type>(locator<meta_ctx>::value_or(), std::forward<Type>(value));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user