c++ - Comma operator with static_assert() -


when trying evaluate comma operator static_assert argument compilation fails

void fvoid() {}  int main() {     int = (1, 2); // a=2     int b = (fvoid(), 3); // b=3      int d = ( , 5);     //        ^     // error: expected primary-expression before ',' token. ok      int c = (static_assert(true), 4);     //       ^~~~~~~~~~~~~     // error: expected primary-expression before 'static_assert'. why? } 

it looks static_assert() doesn't resolve void after compiling. didn't manage find regarding in standard. there way use comma operator or use in line other expression (without semicolon)?

no, there not. language grammar requires semicolon @ end of static assert declaration.

n4140 §7 [dcl.dcl]/1

static_assert-declaration:

​ ​ ​ ​static_assert ( constant-expression , string-literal ) ;


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -