Skip to content

Commit

Permalink
add remove_cvref
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahm-LANL committed Apr 22, 2024
1 parent f519eb0 commit d7f913e
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions singularity-eos/base/variadic_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,26 @@ namespace variadic_utils {
// Some generic variatic utilities
// ======================================================================

// C++14 implementation of std::remove_cvref (available since C++20)
// credit to CJ + Diego
template <typename T>
struct remove_cvref {
typedef std::remove_cv_t<std::remove_reference_t<T>> type;
};

// Helper types
template <typename T>
using remove_cvref_t = typename remove_cvref<T>::type;

// SFINAE to check if a value is a null ptr
template <typename T, typename = typename std::enable_if<
std::is_pointer<typename std::remove_reference<
typename std::remove_cv<T>::type>::type>::value>::type>
constexpr inline bool is_nullptr(T &&t) {
std::is_pointer<remove_cvref_t<T>>::value>::type>
inline bool is_nullptr(T &&t) {
return std::forward<T>(t) == nullptr;
}
template <typename T,
typename std::enable_if<!std::is_pointer<typename std::remove_reference<
typename std::remove_cv<T>::type>::type>::value>::type * = nullptr>
constexpr inline bool is_nullptr(T &&) {
template <typename T, typename std::enable_if<
!std::is_pointer<remove_cvref_t<T>>::value>::type * = nullptr>
inline bool is_nullptr(T &&) {
return false;
}

Expand Down

0 comments on commit d7f913e

Please sign in to comment.