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

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

Calling constructors in c++ without new

...ST: " << __FUNCTION__ << std::endl; A a(__FUNCTION__); static_cast<void>(a); // avoid warnings about unused variables } void assignment() { std::cerr << std::endl << "TEST: " << __FUNCTION__ << std::endl; A a = A(__FUNCTION__); static_ca...
https://stackoverflow.com/ques... 

How do I remove code duplication between similar const and non-const member functions?

...return c; } char & get() { return const_cast<char &>(static_cast<const C &>(*this).get()); } char c; }; The two casts and function call may be ugly but it's correct. Meyers has a thorough explanation why. ...
https://stackoverflow.com/ques... 

How to return an array from JNI to Java?

...2 lists , one x and another is y) static jclass arrayListCls = static_cast<jclass>(env->NewGlobalRef(env->FindClass("java/util/ArrayList"))); jclass floatCls = env->FindClass("java/lang/Float"); //env initialization of list object and float ...
https://stackoverflow.com/ques... 

C++ templates Turing-complete?

...sition = config::position }; typedef typename Conditional< static_cast<int>(GetSize<typename config::input>::value) <= static_cast<int>(position), AppendItem<InputBlank, typename config::input>, Identity<typename config::inpu...
https://stackoverflow.com/ques... 

In what cases do I use malloc and/or new?

...5]; }; int main() { foo *f1 = malloc(1); // error, no cast foo *f2 = static_cast<foo*>(malloc(sizeof(foo))); foo *f3 = static_cast<foo*>(malloc(1)); // No error, bad } It's worse than that though. If the type in question is POD (plain old data) then you can semi-sensibly use mal...
https://www.tsingfun.com/it/cpp/2102.html 

error: cannot dynamic_cast ‘b’ (of type ‘class Base*’) to type ‘c...

...e type is not polymorphic)在将父类型转换为子类型时,可以使用static_cast和dynamic_cast.如果使用dynamic_cast,它要求父类必须为多态的,即要求至少有一个虚函数,因此...在将父类型转换为子类型时,可以使用static_cast和dynamic_cast.如果使用dynamic_...
https://www.tsingfun.com/it/cp... 

c++11右值引用、std::move移动语义、std::forward完美转发的一些总结 - C/C...

...于移动语义。从实现上讲,它基本等同于一个类型转换:static_cast<T&&>(lvalue);特别 std::move 实际上并不能移动任何东西,它唯一的功能是将一个左值强制转换为右值引用,继而用于移动语义。从实现上讲,它基本等同于一个类...
https://stackoverflow.com/ques... 

A positive lambda: '+[]{}' - What sorcery is this? [duplicate]

...se it to pass by value instead of reference. The better way would be with static_cast&lt;T&gt;(lvalue) to get a prvalue of type T from an lvalue. "customary to use a generic function called val()": This isn't clear, can you show an example/link of such a val() function? – And...
https://stackoverflow.com/ques... 

How to use enums as flags in C++?

...; inline AnimalFlags operator|(AnimalFlags a, AnimalFlags b) { return static_cast&lt;AnimalFlags&gt;(static_cast&lt;int&gt;(a) | static_cast&lt;int&gt;(b)); } Etc. rest of the bit operators. Modify as needed if the enum range exceeds int range. ...
https://stackoverflow.com/ques... 

std::wstring VS std::string

...strlen(text); i &lt; iMax; ++i) { std::cout &lt;&lt; " " &lt;&lt; static_cast&lt;unsigned int&gt;( static_cast&lt;unsigned char&gt;(text[i]) ); } std::cout &lt;&lt; std::endl &lt;&lt; std::endl ; // - - - const wchar_t ...