草庐IT

Implicit_cast

全部标签

ios - LLDB( swift ): Casting Raw Address into Usable Type

是否有LLDB命令可以将原始地址转换为可用的Swift类?例如:(lldb)po0x7df67c50asMKPinAnnotationView我知道这个地址指向一个MKPinAnnotationView,但它不在我可以选择的框架中。但是,我想将原始地址转换为MKPinAnnotationView,以便我可以检查它的属性。这可能吗? 最佳答案 在Xcode8.2.1和Swift3下,lldb命令po或p将不起作用与类型变量。您将需要使用快速命令print来检查类型化对象实例的属性。(感谢cbowns'sanswer!)例如:expr-

c# - InvalidCastException : Unable To Cast Objects of type [base] to type [subclass]

我有一个继承自MembershipUser的自定义CustomMembershipUser。publicclassConfigMembershipUser:MembershipUser{//customstuff}我正在使用Linq-to-SQL从数据库中读取并获取用户实体;为了使此功能成为MembershipUser,我定义了一个显式转换:publicstaticexplicitoperatorMembershipUser(Useruser){DateTimenow=DateTime.Now;if(user==null)returnnull;returnnewMembershipUs

c - 错误 : implicit declaration of function 'create_proc_read_entry' [-Werror=implicit-function-declaration]

我正在尝试在内核3.13上编译内核模块,但出现此错误:error:implicitdeclarationoffunction'create_proc_read_entry'[-Werror=implicit-function-declaration]我谷歌了一下,没有找到任何回应。这是引用此错误的代码部分:#if(LINUX_VERSION_CODE我能得到帮助吗?我真的不知道出了什么问题。可能是需要补丁的内核3.13。我在某处(在KERNEL3.10上)读到内核需要补丁。谁能告诉我在哪里可以获得3.13内核补丁以最终解决问题。谢谢 最佳答案

kotlin - 处理这种情况的最佳方法是 "smart cast is imposible"

我想知道处理这种情况的最佳方法是什么classPerson(varname:String?=null,varage:Int?=null){funtest(){if(name!=null&&age!=null)doSth(name,age)//smartcastimposible}fundoSth(someValue:String,someValue2:Int){}}调用doSth方法并确保name和age为ntnull的最简单方法是什么?我正在寻找一些简单的东西,比如我会简单地使用let的可变场景name?.let{doSth(it)} 最佳答案

c++ - 为什么我需要从 `long &` 到 `int &` 的 reinterpret_cast,两者都是 32 位 (Windows LLP64)?

我在跨平台环境中使用Qt。我们遇到了以下问题:在Windows上,int和longint都是32位整数;在64位MacOS和Linux上,int是32位的,longint是64位的(参见https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models)。因此,跨平台库倾向于提供它们自己的固定位类型定义。在Windows上,Qt将quint32定义为unsignedint并且不使用unsignedlong整数。另一个库将其Uint32定义为unsignedlong。因此,两者实际上都是32位无符号整数,但具有不同的原始数据

c++ - 如何很好地将 "cast"qint64 转换为 QProgressBar 的 int

我正在使用QFtp(是的..我知道)并且一切正常。使用他们自己示例中的代码作为指导。http://doc.qt.io/archives/qt-4.7/network-qftp-ftpwindow-cpp.html我遇到的唯一问题是在发送(或接收)大文件(比如3GB)时进度条出现故障。这是由于从qint64到int的转换:voidFtpWindow::updateDataTransferProgress(qint64readBytes,qint64totalBytes){progressDialog->setMaximum(totalBytes);progressDialog->setV

C++ 是否 reinterpret_cast 总是返回结果?

我有两个类,A和B。A是B的父类,我有一个函数接收指向A类型类的指针,检查它是否也是B类型,如果是将调用另一个函数,该函数接受一个指向类型B的类的指针。当函数调用另一个函数时,我提供reinterpret_cast(a)作为参数。如果这看起来模棱两可,这里有一个代码示例:voidabc(A*a){if(a->IsA("B")){//pleasedontworrymuchaboutthisline,//myrealconcernisthereinterpret_castdef(reinterpret_cast(a));};};现在您知道我是如何调用“def”的了,我想知道reinterp

c++ - 有效 C++ : Item 41 - confusion about Implicit interfaces

我正在阅读EffectiveC++,第41条,标题为“理解隐式接口(interface)和编译时多态性”,它给出了这个例子和下一个解释,但我不明白这部分。templatevoiddoProcessing(T&w){if(w.size()>10&&w!=someNastyWidget){......,Tmustsupportasizememberfunction,.....,Butthismemberfunctionneednotreturnanintegraltype.Itneednotevenreturnanumerictype.Forthatmatter,itneednoteven

c++ - 如何避免在 C++ 中将 const_cast 与 std::vector::erase() 一起使用?

我有这样一个类:templateclassAdjacencyList{public:voiddelete_node(constT&);protected:consttypenamestd::vector::const_iterator_iterator_for_node(conststd::vector&,constT&);};templatevoidAdjacencyList::delete_node(constT&node){_nodes.erase(_iterator_for_node(_nodes,node));}templateconsttypenamestd::vector

c++ - 使用默认值而不是异常来 boost numeric_cast<>?

每当boost的numeric_cast转换失败,抛出异常。boost中是否有类似的模板让我指定一个默认值,或者在这种情况下捕获异常是我唯一能做的?我不太担心所有额外异常处理的性能,但我宁愿使用标准模板也不愿编写无用的包装函数。另外,根据以往的经验,我认为boost很有可能真的有我想的,只是一直没有找到。 最佳答案 numeric_cast函数只是调用boost::numeric::converter具有默认参数的模板类。其中一个参数是OverflowHandler,默认值为def_overflow_handler,但您可以指定si