StackOverflow Questions for Tag: static-assert

Khaled Alshaya
Khaled Alshaya

Reputation: 96929

What does static_assert do, and what would you use it for?

Score: 165

Views: 111055

Answers: 10

Read More
Kerrek SB
Kerrek SB

Reputation: 477640

Static assertion that a base pointer "equals" a derived pointer

Score: 4

Views: 847

Answers: 2

Read More
Kalinovcic
Kalinovcic

Reputation: 568

Compile-time check to make sure that there is no padding anywhere in a struct

Score: 14

Views: 3375

Answers: 5

Read More
leek
leek

Reputation: 954

Why is a dependent expression not diagnosed as an error in a false if-constexpr block even if it is always a semantic error

Score: 2

Views: 65

Answers: 0

Read More
curiousguy12
curiousguy12

Reputation: 1807

static_assert rejected in consteval constructor

Score: 1

Views: 133

Answers: 2

Read More
Patrick Fromberg
Patrick Fromberg

Reputation: 1417

Compile time check that only one instance of a class is instantiated in the same scope

Score: 1

Views: 125

Answers: 1

Read More
sharptooth
sharptooth

Reputation: 170559

static_assert not working in Visual C++ 10

Score: 2

Views: 3388

Answers: 2

Read More
Swudu Susuwu
Swudu Susuwu

Reputation: 89

How to do C++ Contracts such that compilers can use once support comes for this (such as `float f(X *x)[[expects:x]]` or `f(X *x) [[ensures: x->u]])`?

Score: 1

Views: 206

Answers: 0

Read More
Xeo
Xeo

Reputation: 131907

Integrate type name in static_assert output?

Score: 72

Views: 23636

Answers: 5

Read More
Trade-Ideas Philip
Trade-Ideas Philip

Reputation: 1247

What's the right way to call static_assert(false)?

Score: 11

Views: 6862

Answers: 5

Read More
Teivaz
Teivaz

Reputation: 5675

Comma operator with static_assert()

Score: 7

Views: 3409

Answers: 4

Read More
Solo
Solo

Reputation: 439

C++ constexpr operations on each element of a constexpr array

Score: 6

Views: 373

Answers: 6

Read More
Wolf
Wolf

Reputation: 10236

Compile-time check for -fsingle-precision-constant

Score: 1

Views: 83

Answers: 1

Read More
Johan Lundberg
Johan Lundberg

Reputation: 27078

How does a failed static_assert work in an if constexpr (false) block?

Score: 75

Views: 30931

Answers: 8

Read More
gebjon
gebjon

Reputation: 131

gcc unexpected C static_assert error: expression in static assertion is not constant

Score: 3

Views: 143

Answers: 1

Read More
NYA
NYA

Reputation: 9

Trigger compile errors in constexpr functions

Score: 0

Views: 44

Answers: 0

Read More
Dominik Weber
Dominik Weber

Reputation: 57

static_assert vs C_ASSERT - which one to use?

Score: 0

Views: 104

Answers: 1

Read More
Sir
Sir

Reputation: 347

How to assert size of `usize` to drop support for incompatible platforms?

Score: 2

Views: 480

Answers: 1

Read More
glades
glades

Reputation: 4892

Trigger (static_) assert when compiler is able to determine parameter constant at compile time

Score: 1

Views: 141

Answers: 2

Read More
SHIPWECK
SHIPWECK

Reputation: 99

Is there a performance benefit to using c++'s std(::ranges)::uninitialized_... algorithms, and is it worth not having constexpr?

Score: 0

Views: 102

Answers: 1

Read More
PreviousPage 1Next