static_assert With No Message

C++17 has built upon the previous functionality of 'static_assert' to provide a more convenient experience.

static_assert

This feature adds a new overload for static_assert. It enables you to have the condition inside static_assert without passing the message.

It will be compatible with other asserts like BOOST_STATIC_ASSERT. Programmers with boost experience will now have no trouble switching to C++17 static_assert.

static_assert(std::is_arithmetic_v<T>, "T must be arithmetic");
static_assert(std::is_arithmetic_v<T>); // no message needed since C++17

In many cases, the condition you check is expressive enough and doesn’t need to be mentioned​ in the message string.

Extra Info: The change was proposed in: N3928.

Fix: Different begin and end Types In Range-Based For Loop

C++11 added range-based for loops:

Get hands-on with 1400+ tech skills courses.