Skip to content
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

static if ... static assert pattern #11

Open
jwhear opened this issue Jan 16, 2012 · 2 comments
Open

static if ... static assert pattern #11

jwhear opened this issue Jan 16, 2012 · 2 comments
Assignees

Comments

@jwhear
Copy link
Contributor

jwhear commented Jan 16, 2012

I noticed that the following pattern appears regularly (example 22.1.4):

static if (someCondition)
    static assert(0, "message");

When the code could be written simply as

static assert(someCondition, "message");

If this is a deliberate style decision, you might consider making a note of it somewhere and informing the reader that static assert takes an expression just like its runtime cousin.

@PhilippeSigaud
Copy link
Owner

On Mon, Jan 16, 2012 at 21:34, Justin whear
<reply+i-2860049-e5ff9b107ee42541fc177e81477796b037de6899-> I noticed
that the following pattern appears regularly (example 22.1.4):

   static if (someCondition)
       static assert(0, "message");

When the code could be written simply as

   static assert(someCondition, "message");

If this is a deliberate style decision, you might consider making a note of it somewhere and informing the reader that static assert takes an expression just like its runtime cousin.

You're right. Most of the time, it's inside a bunch of nested static
if's, but not always. In the particular example you cited, it would be
clearer your way. I'll make it an issue, so as not to forget.

I do speak about static assert in §3.3.4 (bottom of p.18), but I will
add your comment.

@PhilippeSigaud
Copy link
Owner

Ow, it's becoming a bit too late in here. That's already an issue.

@ghost ghost assigned PhilippeSigaud Jan 16, 2012
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

No branches or pull requests

2 participants