Skip to content

Commit

Permalink
Clang workarounds (#867)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr authored Mar 4, 2021
1 parent 29c7a25 commit c350ff3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 43 deletions.
2 changes: 1 addition & 1 deletion strings/base_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ namespace winrt::impl

[[noreturn]] inline void __stdcall fallback_RoFailFastWithErrorContext(int32_t) noexcept
{
std::terminate();
abort();
}
}

Expand Down
86 changes: 44 additions & 42 deletions strings/base_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,50 @@ WINRT_EXPORT namespace winrt

struct guid
{
private:

template <typename TStringView>
static constexpr guid parse(TStringView const value) noexcept
{
if (value.size() != 36 || value[8] != '-' || value[13] != '-' || value[18] != '-' || value[23] != '-')
{
std::terminate();
}

return
{
impl::uint8_to_uint32
(
impl::hex_to_uint8(value[0], value[1]),
impl::hex_to_uint8(value[2], value[3]),
impl::hex_to_uint8(value[4], value[5]),
impl::hex_to_uint8(value[6], value[7])
),
impl::uint8_to_uint16
(
impl::hex_to_uint8(value[9], value[10]),
impl::hex_to_uint8(value[11], value[12])
),
impl::uint8_to_uint16
(
impl::hex_to_uint8(value[14], value[15]),
impl::hex_to_uint8(value[16], value[17])
),
{
impl::hex_to_uint8(value[19], value[20]),
impl::hex_to_uint8(value[21], value[22]),
impl::hex_to_uint8(value[24], value[25]),
impl::hex_to_uint8(value[26], value[27]),
impl::hex_to_uint8(value[28], value[29]),
impl::hex_to_uint8(value[30], value[31]),
impl::hex_to_uint8(value[32], value[33]),
impl::hex_to_uint8(value[34], value[35]),
}
};
}

public:

uint32_t Data1;
uint16_t Data2;
uint16_t Data3;
Expand Down Expand Up @@ -124,48 +168,6 @@ WINRT_EXPORT namespace winrt
guid(parse(value))
{
}

private:

template <typename TStringView>
static constexpr guid parse(TStringView const value) noexcept
{
if (value.size() != 36 || value[8] != '-' || value[13] != '-' || value[18] != '-' || value[23] != '-')
{
std::terminate();
}

return
{
impl::uint8_to_uint32
(
impl::hex_to_uint8(value[0], value[1]),
impl::hex_to_uint8(value[2], value[3]),
impl::hex_to_uint8(value[4], value[5]),
impl::hex_to_uint8(value[6], value[7])
),
impl::uint8_to_uint16
(
impl::hex_to_uint8(value[9], value[10]),
impl::hex_to_uint8(value[11], value[12])
),
impl::uint8_to_uint16
(
impl::hex_to_uint8(value[14], value[15]),
impl::hex_to_uint8(value[16], value[17])
),
{
impl::hex_to_uint8(value[19], value[20]),
impl::hex_to_uint8(value[21], value[22]),
impl::hex_to_uint8(value[24], value[25]),
impl::hex_to_uint8(value[26], value[27]),
impl::hex_to_uint8(value[28], value[29]),
impl::hex_to_uint8(value[30], value[31]),
impl::hex_to_uint8(value[32], value[33]),
impl::hex_to_uint8(value[34], value[35]),
}
};
}
};

inline bool operator==(guid const& left, guid const& right) noexcept
Expand Down

0 comments on commit c350ff3

Please sign in to comment.