-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SUGGESTION] How to cast int to std::size_t #104
Labels
Comments
This is now resolved, and the example below works:
Thanks! |
Excellent solution! Thanks for cooperating on that! |
I thought that there had been a discussion about how to make the |
There was #63. |
Thanks Johel, I think that's what I was thinking of. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks to #93 I was able to implement the
main
function that takes arguments.but then
argv
is a pointer and the pointer arithmetic checks will kick in (another PR is needed to achieve that - already on the list). From the messages provided by the safety check, I know that we recommend usingstd::span
.When I try to construct
std::span
I can use pointer andstd::size_t
argument to construct the span butargc
is anint
. How to do narrowing conversion in cpp2 way? usingargc as std::size_t
is not working as it matchesand fails miserably as a runtime crash :(.
What worked for me right now is
but I believe we can do better.
By the way, returning
nonesuch
without a warning when something doesn't match defined cases is a really bad idea - I was looking for an error why the below code ends with a crash:Probably it is better to do
static_assert
for cases that don't match or something that will give a hint of what is not working.The text was updated successfully, but these errors were encountered: