大约有 118 项符合查询结果(耗时:0.0280秒) [XML]

https://stackoverflow.com/ques... 

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

Both static_cast and reinterpret_cast seem to work fine for casting void* to another pointer type. Is there a good reason to favor one over the other? ...
https://stackoverflow.com/ques... 

How can I output the value of an enum class in C++11

...d to explicitly convert it to an integer using a cast: std::cout << static_cast<std::underlying_type<A>::type>(a) << std::endl; You may want to encapsulate the logic into a function template: template <typename Enumeration> auto as_integer(Enumeration const value) ...
https://stackoverflow.com/ques... 

Is it possible to print a variable's type in standard C++?

...me<decltype((ci))>() << '\n'; std::cout << "decltype(static_cast<int&>(i)) is " << type_name<decltype(static_cast<int&>(i))>() << '\n'; std::cout << "decltype(static_cast<int&&>(i)) is " << type_name<decltyp...
https://stackoverflow.com/ques... 

uint8_t can't be printed with cout

... Since C style casts are frowned upon, wouldn't it be better to do a static_cast? – Tim Seguine Oct 24 '13 at 12:09 37 ...
https://stackoverflow.com/ques... 

How does std::forward work? [duplicate]

...orward does according to the standard: §20.2.3 [forward] p2 Returns: static_cast<T&&>(t) (Where T is the explicitly specified template parameter and t is the passed argument.) Now remember the reference collapsing rules: TR R T& & -> T& // lvalue referen...
https://stackoverflow.com/ques... 

dynamic_cast and static_cast in C++

... Here's a rundown on static_cast<> and dynamic_cast<> specifically as they pertain to pointers. This is just a 101-level rundown, it does not cover all the intricacies. static_cast< Type* >(ptr) This takes the pointer in ptr ...
https://stackoverflow.com/ques... 

How does std::move() transfer values into RValues?

...remove_reference<T>::type&& move(T&& arg) { return static_cast<typename remove_reference<T>::type&&>(arg); } Let's start with the easier part - that is, when the function is called with rvalue: Object a = std::move(Object()); // Object() is temporary,...
https://stackoverflow.com/ques... 

Can an enum class be converted to the underlying type?

...ype typedef std::underlying_type<my_fields>::type utype; utype a = static_cast<utype>(my_fields::field); With this, you don't have to assume the underlying type, or you don't have to mention it in the definition of the enum class like enum class my_fields : int { .... } or so. You c...
https://stackoverflow.com/ques... 

Connecting overloaded signals and slots in Qt 5

...h one you want to pick, by casting it to the right type: connect(spinbox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), slider, &QSlider::setValue); I know, it's ugly. But there's no way around this. Today's lesson is: do not overload your signals and slots!...
https://stackoverflow.com/ques... 

How do I specify a pointer to an overloaded function?

... You can use static_cast<>() to specify which f to use according to the function signature implied by the function pointer type: // Uses the void f(char c); overload std::for_each(s.begin(), s.end(), static_cast<void (*)(char)&g...