Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions llvm/include/llvm/Support/PointerLikeTypeTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#ifndef LLVM_SUPPORT_POINTERLIKETYPETRAITS_H
#define LLVM_SUPPORT_POINTERLIKETYPETRAITS_H

#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/DataTypes.h"
#include <cassert>
#include <type_traits>
Expand All @@ -31,25 +32,15 @@ struct ConstantLog2
: std::integral_constant<size_t, ConstantLog2<N / 2>::value + 1> {};
template <> struct ConstantLog2<1> : std::integral_constant<size_t, 0> {};

// Provide a trait to check if T is pointer-like.
template <typename T, typename U = void> struct HasPointerLikeTypeTraits {
static const bool value = false;
};

// sizeof(T) is valid only for a complete T.
template <typename T>
struct HasPointerLikeTypeTraits<
T, decltype((sizeof(PointerLikeTypeTraits<T>) + sizeof(T)), void())> {
static const bool value = true;
};
using check_IsPointerLike =
std::void_t<decltype(sizeof(PointerLikeTypeTraits<T>)),
decltype(sizeof(T))>;

template <typename T> struct IsPointerLike {
static const bool value = HasPointerLikeTypeTraits<T>::value;
};

template <typename T> struct IsPointerLike<T *> {
static const bool value = true;
};
// Provide a trait to check if T is pointer-like.
template <typename T>
struct IsPointerLike : is_detected<check_IsPointerLike, T> {};
} // namespace detail

// Provide PointerLikeTypeTraits for non-cvr pointers.
Expand Down
Loading