Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
I want to use an array-literal of literals in a _Static_assert, but I get a compiler error saying this is not a constant expression
_Static_assert((int[]){2, 1, 0}[2], "err");
Is there a way to make it work?
_Static_assert
constexpr
_Static_assert((constexpr int[]){2, 1, 0}[2], "err");
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
_Static_assert. The C23 will introduceconstexprand allow it for storage specifier of compound literal what may make your code work._Static_assert((constexpr int[]){2, 1, 0}[2], "err");?