Skip to content
This repository was archived by the owner on Apr 8, 2026. It is now read-only.

C++: Literals for basic types#359

Merged
chfast merged 5 commits intomasterfrom
literals
Jul 24, 2019
Merged

C++: Literals for basic types#359
chfast merged 5 commits intomasterfrom
literals

Conversation

@chfast
Copy link
Copy Markdown
Member

@chfast chfast commented Jul 22, 2019

No description provided.

@chfast chfast marked this pull request as ready for review July 23, 2019 12:46
@chfast chfast requested a review from axic July 23, 2019 12:46
constexpr uint8_t parse_hex_digit(uint8_t d) noexcept
{
return static_cast<uint8_t>(
(d >= '0' && d <= '9') ? d - '0' : (d >= 'a' && d <= 'f') ? d - 'a' + 10 : d - 'A' + 10);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance to abort on invalid hex digits? E.g. 0x123kkx_address ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be C++ parser error. But I've found in C++17 you can have literals like 0x0.000000000000000000000000000000000000p0_address so I added additional checks.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reckon it is not easy to add a test case (e.g. file which would not compile)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not without creating custom testing framework in CMake.

@axic
Copy link
Copy Markdown
Member

axic commented Jul 23, 2019

Need to apply renaming to changelog.

@chfast chfast force-pushed the literals branch 2 times, most recently from 5d9a3e8 to ed8ffa4 Compare July 23, 2019 14:55

namespace literals
{
namespace internal
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should internal stuff better go into separate header?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far I'm ok with having single header for C++ (now it's even better when helpers.hpp is gone).

@chfast chfast merged commit 9b2df0f into master Jul 24, 2019
@chfast chfast deleted the literals branch July 24, 2019 12:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants