Skip to content

add error messages to static_assert#68

Merged
neatudarius merged 11 commits intobemanproject:mainfrom
changkhothuychung:static-msg
Oct 17, 2024
Merged

add error messages to static_assert#68
neatudarius merged 11 commits intobemanproject:mainfrom
changkhothuychung:static-msg

Conversation

@changkhothuychung
Copy link
Contributor

@changkhothuychung changkhothuychung commented Oct 3, 2024

Fix #50

I will keep adding more messages to the static_assert's

@neatudarius neatudarius self-assigned this Oct 3, 2024
@changkhothuychung
Copy link
Contributor Author

any suggestion what error msg I should give for this case?

static_assert((!std::is_same_v<T, std::remove_cv_t<in_place_t>>) && (!std::is_same_v<std::remove_cv_t<T>, nullopt_t>))

@steve-downey
Copy link
Member

any suggestion what error msg I should give for this case?

static_assert((!std::is_same_v<T, std::remove_cv_t<in_place_t>>) && (!std::is_same_v<std::remove_cv_t<T>, nullopt_t>))

Something like, "T must not be in_place_t or nullopt_t" ?

@changkhothuychung
Copy link
Contributor Author

any suggestion what error msg I should give for this case?
static_assert((!std::is_same_v<T, std::remove_cv_t<in_place_t>>) && (!std::is_same_v<std::remove_cv_t<T>, nullopt_t>))

Something like, "T must not be in_place_t or nullopt_t" ?

Thanks! I see there is a remove_cv_t, I was thinking I should say something like "T without cv qualification must not be nullopt_t"

Copy link
Member

@neatudarius neatudarius left a comment

Choose a reason for hiding this comment

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

Current PR status LGTM. Waiting for new version

@changkhothuychung
Copy link
Contributor Author

I tried to add a line

beman::optional26::optional<beman::optional26::nullopt_t> op;

to file concept_checks.cpp

Here is the error log before the message is added

optional26/include/beman/optional26/optional.hpp:290:5: error: static assertion failed
      due to requirement '!std::is_same_v<beman::optional26::nullopt_t, beman::optional26::nullopt_t>'
    static_assert(
    ^
/Users/nguyennhat/Desktop/optional26/examples/concept_checks.cpp:97:63: note: in instantiation of template class
      'beman::optional26::optional<beman::optional26::nullopt_t>' requested here
    beman::optional26::optional<beman::optional26::nullopt_t> op;

Here is the error log after the message is added

optional26/include/beman/optional26/optional.hpp:290:5: error: static assertion failed
      due to requirement '!std::is_same_v<beman::optional26::nullopt_t, beman::optional26::nullopt_t>': T must not be in_place_t or
      nullopt_t
    static_assert(
    ^
/Users/nguyennhat/Desktop/optional26/examples/concept_checks.cpp:97:63: note: in instantiation of template class
      'beman::optional26::optional<beman::optional26::nullopt_t>' requested here
    beman::optional26::optional<beman::optional26::nullopt_t> op;

@changkhothuychung
Copy link
Contributor Author

@neatudarius @steve-downey
I dont have permission to merge, can you run the CI again and if things look good, can you merge for me? Thanks

@steve-downey
Copy link
Member

Sure, not a problem.

@neatudarius
Copy link
Member

@changkhothuychung , please fix precommit before merge. Otherwise LGTM

@neatudarius
Copy link
Member

neatudarius commented Oct 17, 2024

@changkhothuychung , one more try? I will check repo settings to automatically run CI for any PR without approval.

@neatudarius
Copy link
Member

@changkhothuychung , one more try? I will check repo settings to automatically run CI for any PR without approval.

It should always run CI when you push.

@neatudarius neatudarius merged commit a271c96 into bemanproject:main Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

static_assert "Should have a reason"

3 participants