implicit

Implicit type conversion rules in C++ operators

早过忘川 提交于 2019-12-16 19:04:36
问题 I want to be better about knowing when I should cast. What are the implicit type conversion rules in C++ when adding, multiplying, etc. For example, int + float = ? int * float = ? float * int = ? int / float = ? float / int = ? int / int = ? int ^ float = ? et cetera... Will the expression always be evaluated as the more precise type? Do the rules differ for Java? Please correct me if I have worded this question inaccurately. 回答1: In C++ operators (for POD types) always act on objects of the

No Implicit View Available

丶灬走出姿态 提交于 2019-12-14 01:07:21
问题 When trying to bulk load a list of DBObject 's via insert, I get no implicit view available . collection.insert(listObjects) // listObjects is a List[DBObject] [error]Test.scala:139: No implicit view available from List[com.mongodb.casba h.Imports.DBObject] => com.mongodb.casbah.Imports.DBObject. What does this error mean? How can I resolve? Reference: def insert [A] (docs: List[A])(implicit arg0: (A) ⇒ DBObject) : WriteResult 回答1: The method insert will take any List, but to store the data

C Implicit declaration differs from internal function declaration

懵懂的女人 提交于 2019-12-13 23:24:10
问题 I'm having some trouble with C standard functions. As an example, I'm getting that error in the memcpy function, even passing the right arguments to it. I've included a header as #include "header.h", and I've included , and so in the "header.h" file. (I'm also getting this error with strcpy, strtok, and some other standard functions, all respective headers included in "header.h") Can anyone please help me with this? I'm running out of time to deploy this work... Thanks in advance 回答1: It

Android - Read a File

跟風遠走 提交于 2019-12-13 18:33:13
问题 I am trying to read a list of exercises from a file Exercises.txt in my /assests folder and I've found plenty of examples how to, but I keep getting the error "context cannot be resolved" and if I manage to fix that, then I get "Default constructor cannot handle exception type IOException thrown by implicit super constructor. Must define an explicit constructor" Here is my code: class ChooseExercises extends ListActivity{ String[] exercises; AssetManager am = context.getAssets(); //Error 1

Is it inefficient to use implicit struct creation (a.k.a. shorthand or literal notation) in function parameters?

北慕城南 提交于 2019-12-13 17:59:08
问题 Bear with me on this... Say I have an existing struct: <cfset struct1 = {key1 = "foo", key2 = "bar"}> ...to which I want to add some key/value pairs. The typical approach would be something like: <cfset struct1.key3 = "baz"> <cfset struct1.key4 = "qux"> <cfset struct1.key5 = "quux"> Alternatively, I could use structAppend(): <cfset struct2 = {key3 = "baz", key4 = "qux", key5 = "quux"}> <cfset structAppend(struct1, struct2, false)> ... which has the added bonus of allowing me to control

How to override an implicit value, that is imported?

那年仲夏 提交于 2019-12-13 16:21:45
问题 I have tried solutions, described in How to override an implicit value?, but it does not help. Here is a code example. A definition of TestImplicit abstraction with 2 different implementations (analogue of ExecutionContextExecutor ): trait TestImplicit { def f(s:String):Unit } object TestImplicitImpl1 extends TestImplicit { override def f(s: String): Unit = println(s"1: $s") } object TestImplicitImpl2 extends TestImplicit { override def f(s: String): Unit = println(s"2: $s") } And in the

Implicit Declaration of Function in C UNIX

元气小坏坏 提交于 2019-12-13 14:40:14
问题 In the following code, I get a warning that there is an implicit declaration of function getpgid. I know its only a warning, but its for a class and the professor wants us to treat warnings as errors. So, help please. I have included the appropriate header file as well so I have no idea whats wrong: #include <unistd.h> pid_t pid, pgid; if ((pgid = getpgid(pid)) < 0) { app_error("Failure to get process group ID"); } 回答1: From the man page: Feature Test Macro Requirements for glibc (see feature

Templates with implicit parameters, forward declaration, C++

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 12:05:35
问题 There is a declaration of template class with implicit parameters: List.h template <typename Item, const bool attribute = true> class List: public OList <item, attribute> { public: List() : OList<Item, attribute> () {} .... }; I tried to use the fllowing forward declaration in a different header file: Analysis.h template <typename T, const bool attribute = true> class List; But G++ shows this error: List.h:28: error: redefinition of default argument for `bool attribute' Analysis.h:43: error:

How to connect to a implicit FTPS server with nodeJS?

扶醉桌前 提交于 2019-12-12 16:02:15
问题 For a project I have to connect to a FTPS server over a implicit connection. I tried with node-ftp, because it seems that this is the only library, that supports the implicit connection. I connect using the following code: var ftpC = new FTPClient(); ftpC.on('ready', function () { console.log('Connection successful!'); }); ftpC.on('error', function (err) { console.log(err); }); console.log('Try to connect to FTP Server...'); ftpC.connect({ host: HOST_TO_CONNECT, port: 990, secure: 'implicit',

Get Runtime Type picked by implicit evidence

被刻印的时光 ゝ 提交于 2019-12-12 14:29:42
问题 Suppose I have a set of converters to String, as a Type class: import scala.reflect.runtime.universe._ abstract class ToStringConverter[T] { def convert(value: T): String } implicit object IntToStringConverter extends ToStringConverter[Int] { def convert(value: Int) = value.toString } implicit object DoubleStringConverter extends ToStringConverter[Double] { def convert(value: Double) = value.toString } and a convert method that uses the type information to pick right converter: def convert[T]