StackOverflow Questions for Tag: static-cast

Andy
Andy

Reputation: 3274

Should I use static_cast or reinterpret_cast when casting a void* to whatever

Score: 284

Views: 116905

Answers: 9

Read More
Eran
Eran

Reputation: 22030

Why can't static_cast be used to down-cast when virtual inheritance is involved?

Score: 54

Views: 25662

Answers: 6

Read More
Enlico
Enlico

Reputation: 28490

Why can't I static_cast a void* to a pointer-to-function?

Score: 2

Views: 1157

Answers: 2

Read More
Mr.C64
Mr.C64

Reputation: 43004

Proper way of casting pointer types

Score: 73

Views: 123404

Answers: 3

Read More
Muhammad Altaf
Muhammad Altaf

Reputation: 31

static_cast<uint32_t> returns 0 for non-const/constexpr float, holding 2^32 -1 (UINT32_MAX) but returns UINT32_MAX when float is const/constexpr

Score: 3

Views: 95

Answers: 2

Read More
Broothy
Broothy

Reputation: 721

Base to Derived static_cast, not visible relation

Score: 0

Views: 101

Answers: 2

Read More
Jim Carroll
Jim Carroll

Reputation: 61

Is a static_cast from a base to derived class well-defined when both classes have the same layout?

Score: 2

Views: 101

Answers: 2

Read More
gh_shark
gh_shark

Reputation: 13

c++ static_cast to virtual base in runtime

Score: 1

Views: 84

Answers: 1

Read More
Rajeshwar
Rajeshwar

Reputation: 11671

static_cast - Why is it working here?

Score: 2

Views: 2425

Answers: 3

Read More
cao lei
cao lei

Reputation: 1011

Can reinterpret_cast be used to cast a pointer to an unimplemented class pointer"?

Score: 1

Views: 116

Answers: 2

Read More
FrozenHeart
FrozenHeart

Reputation: 20766

reinterpret_cast error for enum

Score: 14

Views: 5931

Answers: 4

Read More
kwunlyou
kwunlyou

Reputation: 77

static_cast derived this object to base class in C++

Score: 1

Views: 8995

Answers: 3

Read More
shawn_halayka
shawn_halayka

Reputation: 106

In C++, what is the standard behaviour of static_cast<float>(some_double_variable)?

Score: 1

Views: 224

Answers: 2

Read More
Thomas Eding
Thomas Eding

Reputation: 1

Is it legal to cast a pointer to array reference using static_cast in C++?

Score: 20

Views: 6658

Answers: 2

Read More
Jerry
Jerry

Reputation: 3

qt5: connect overload signal and slot function with static_cast

Score: 0

Views: 922

Answers: 1

Read More
nyarlathotep108
nyarlathotep108

Reputation: 5521

Has CRTP no compile time check?

Score: 9

Views: 1117

Answers: 3

Read More
Canardini
Canardini

Reputation: 171

How can a function that requires another function as a parameter can be used within a class in c++?

Score: 0

Views: 70

Answers: 1

Read More
Charles
Charles

Reputation: 1239

C++ with MinGW : ignored type qualifier on cast result type : but which qualifier is ignored?

Score: 1

Views: 305

Answers: 1

Read More
Khushi Mittal
Khushi Mittal

Reputation: 33

Why is a Static Cast necessary to avoid overflowing int in a mathematical operation when the result will be stored in a variable large enough?

Score: 0

Views: 80

Answers: 0

Read More
Christopher Miller
Christopher Miller

Reputation: 3461

Is it UB to reinterpret_cast a T* to a uintptr_t, reinterpret_cast that uintptr_t to a void*, then static_cast that void* back to a T*?

Score: 6

Views: 984

Answers: 0

Read More
PreviousPage 1Next