Skip to content

Commit

Permalink
Add checks for void* in get_reference_argument
Browse files Browse the repository at this point in the history
  • Loading branch information
yjiao-cgnx committed Oct 27, 2021
1 parent 07a3cba commit 5561dea
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.vscode
build
build*
2 changes: 1 addition & 1 deletion src/rttr/detail/type/type_register.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class RTTR_API type_register

private:

friend class type;
friend class rttr::type;
template<typename T>
friend class class_;

Expand Down
17 changes: 14 additions & 3 deletions src/rttr/detail/variant/variant_data_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,25 @@ enable_if_t<is_wrapper<T>::value && !is_dereferenceable<Tp>::value, argument> ge
/////////////////////////////////////////////////////////////////////////////////////////

template<typename T>
enable_if_t<!is_wrapper<T>::value &&
is_dereferenceable<T>::value, argument> get_reference_argument(T& value)
{
enable_if_t< !is_wrapper<T>::value && is_dereferenceable<T>::value &&
!std::is_void<typename std::remove_pointer<T>::type>::value, argument> get_reference_argument(T& value)
{
return argument(*value);
}

/////////////////////////////////////////////////////////////////////////////////////////

template<typename T>
enable_if_t<!is_wrapper<T>::value && is_dereferenceable<T>::value &&
std::is_void<typename std::remove_pointer<T>::type>::value, argument> get_reference_argument(T& value)
{
// This is specifically for the scenario when T is void*. And since we cannot actually do anything
// meaningful with a void* variable we will just return an empty argument.
return argument();
}

/////////////////////////////////////////////////////////////////////////////////////////

template<typename T>
enable_if_t<!is_wrapper<T>::value &&
!is_dereferenceable<T>::value, argument> get_reference_argument(T& value)
Expand Down

0 comments on commit 5561dea

Please sign in to comment.