Page MenuHomePhabricator

[libc][NFC] Use RemoveCVType to implement IsIntegral and IsPointerType.

Authored by sivachandra on Jul 16 2020, 12:54 PM.



Added IsSameV as a convenience variable and used it where convenient.

Diff Detail

Event Timeline

sivachandra created this revision.Jul 16 2020, 12:54 PM
abrachet accepted this revision.Jul 16 2020, 3:55 PM
abrachet added inline comments.

Maybe we could have:

template <typename Type> struct IsIntegral {
  using NoCV = RemoveCVType<Type>;
  static constexpr bool Value = IsSame<char, NoCV>::Value ||

It also might make sense to make an std::is_same_v so we don't need to keep adding ::Value


This needs RemoveCV too. As a nit, this and the IsFloatingPointType shouldn't have Type at the end because that sounds like it would be analogous to the type definitions which end in _t like std::remove_cv_t. Although these templates have a Value not Type I think it is still better to leave it off. Especially because the type_traits version of these are just be called std::is_pointer and std::is_floating_point

This revision is now accepted and ready to land.Jul 16 2020, 3:55 PM
  • Add IsSameV
  • Use RemoveCV for IsPointerType as well.
sivachandra marked 2 inline comments as done.

Add a convenience nested type TypeNoCV in IsInteger and IsFloatingPointType.

Add static to a global var.

sivachandra marked an inline comment as done.Jul 16 2020, 5:13 PM
sivachandra added inline comments.

Using inline on variables is a C++ 17 feature. Does static make sense until then? I would expect this var to get optimized out anyway.


Using RemoveCV here now. Will do the renaming in a different pass as obvious. It touches a whole bunch of places.

lntue accepted this revision.Jul 17 2020, 7:37 AM
sivachandra retitled this revision from [libc][NFC] Use RemoveCVType to implement IsIntegral. to [libc][NFC] Use RemoveCVType to implement IsIntegral and IsPointerType..Jul 17 2020, 11:42 AM
sivachandra edited the summary of this revision. (Show Details)
This revision was automatically updated to reflect the committed changes.