[llvm-bugs] [Bug 48860] New: MSVC Compatibility: Implement intrinsics for P0466R5 - Layout-compatibility and Pointer-interconvertibility Traits

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jan 23 12:20:13 PST 2021


https://bugs.llvm.org/show_bug.cgi?id=48860

            Bug ID: 48860
           Summary: MSVC Compatibility: Implement intrinsics for P0466R5 -
                    Layout-compatibility and Pointer-interconvertibility
                    Traits
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mahmoud.g.saleh at gmail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

MSVC recently implemented the following intrinsics needed for P0466R5
Layout-compatibility and Pointer-interconvertibility Traits:

* __builtin_is_layout_compatible
* __builtin_is_pointer_interconvertible_base_of
* __builtin_is_pointer_interconvertible_with_class
* __builtin_is_corresponding_member

MSVC STL is planning to use them in <type_traits> as follows (PR:
https://github.com/microsoft/STL/pull/1575):

// STRUCT TEMPLATE is_layout_compatible
template <class _Ty1, class _Ty2>
struct is_layout_compatible :
bool_constant<__builtin_is_layout_compatible(_Ty1, _Ty2)> {};

template <class _Ty1, class _Ty2>
inline constexpr bool is_layout_compatible_v =
__builtin_is_layout_compatible(_Ty1, _Ty2);

// STRUCT TEMPLATE is_pointer_interconvertible_base_of
template <class _Base, class _Derived>
struct is_pointer_interconvertible_base_of
    : bool_constant<__builtin_is_pointer_interconvertible_base_of(_Base,
_Derived)> {};

template <class _Base, class _Derived>
inline constexpr bool is_pointer_interconvertible_base_of_v =
__builtin_is_pointer_interconvertible_base_of(
    _Base, _Derived);

// FUNCTION TEMPLATE is_pointer_interconvertible_with_class
template <class _ClassTy, class _MemberTy>
_NODISCARD constexpr bool is_pointer_interconvertible_with_class(_MemberTy
_ClassTy::*_Pm) noexcept {
    return __builtin_is_pointer_interconvertible_with_class(_ClassTy, _Pm);
}

// FUNCTION TEMPLATE is_corresponding_member
template <class _ClassTy1, class _ClassTy2, class _MemberTy1, class _MemberTy2>
_NODISCARD constexpr bool is_corresponding_member(_MemberTy1 _ClassTy1::*_Pm1,
_MemberTy2 _ClassTy2::*_Pm2) noexcept {
    return __builtin_is_corresponding_member(_ClassTy1, _ClassTy2, _Pm1, _Pm2);

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210123/f6f6fcb0/attachment.html>


More information about the llvm-bugs mailing list