static_assert - a way to dynamically customize error message

后端 未结 3 639
粉色の甜心
粉色の甜心 2021-01-07 21:20

Is there a way to make static_assert\'s string being dynamically customized and then displayed?
What I mean is something like:

//pseudo code
static_ass         


        
3条回答
  •  离开以前
    2021-01-07 22:04

    The standard specifies the second argument of static_assert to be a string literal, so no chance for computation there as far as I can see (except for preprocessor macros).

    A compiler could extend the standard and allow const-expressions of approporiate type in this position, but I have no idea if any compiler does.

提交回复
热议问题