Skip to content

Commit

Permalink
added compile-time checks
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Mar 1, 2019
1 parent b0d3a84 commit 1ae436c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/entt/meta/meta.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <cassert>
#include <cstddef>
#include <utility>
#include <functional>
#include <type_traits>
#include "../config/config.h"
#include "../core/hashed_string.hpp"
Expand Down Expand Up @@ -2046,8 +2047,10 @@ bool setter([[maybe_unused]] meta_handle handle, [[maybe_unused]] meta_any &any)

if(accepted && clazz) {
if constexpr(std::is_function_v<std::remove_pointer_t<decltype(Data)>>) {
static_assert(std::is_invocable_v<decltype(Data), Type &, data_type>);
Data(*clazz, any.cast<data_type>());
} else if constexpr(std::is_member_function_pointer_v<decltype(Data)>) {
static_assert(std::is_invocable_v<decltype(Data), Type *, data_type>);
(clazz->*Data)(any.cast<data_type>());
}
}
Expand Down

0 comments on commit 1ae436c

Please sign in to comment.