Skip to content

Commit

Permalink
Fix for small bugs in SafePtr/array typedefs
Browse files Browse the repository at this point in the history
  • Loading branch information
sc2ad committed May 15, 2021
1 parent 0a53dbe commit c727f41
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 8 additions & 0 deletions shared/utils/typedefs-array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
#include <vector>
#include <span>

#if __has_include(<concepts>)
#include <concepts>
#elif __has_include(<experimental/concepts>)
#include <experimental/concepts>
#else
#warning "Please have some form of concepts support!"
#endif

template<class T, class U>
/// @brief If type T can be assigned to by type U&&
/// @tparam T The left hand side of the assignment
Expand Down
7 changes: 4 additions & 3 deletions shared/utils/typedefs-wrappers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,11 @@ struct SafePtr {
return std::nullopt;
}

/// @brief Returns true if this instance's internal handle holds a pointer of ANY value (including nullptr)
/// false otherwise.
/// @brief Returns false if this is a defaultly constructed SafePtr, true otherwise.
/// Note that this means that it will return true if it holds a nullptr value explicitly!
/// This means that you should check yourself before calling anything using the held T*.
operator bool() const noexcept {
return *internalHandle != nullptr;
return (bool)internalHandle;
}

/// @brief Dereferences the instance pointer to a reference type of the held instance.
Expand Down

0 comments on commit c727f41

Please sign in to comment.